[Solved] CSE140: Lab/HW #1 -Machine Language

$25

File Name: CSE140:_Lab/HW_#1_-Machine_Language.zip
File Size: 329.7 KB

SKU: [Solved] CSE140: Lab/HW #1 -Machine Language Category: Tag:
5/5 - (1 vote)

Since computer hardware can only communicate in 0s and 1s, our programs written in MIPS must be translated into machine code containing only 0s and 1s so that they can be executed. In this lab, we will review the conversions between MIPS and machine code.

Getting started

We will use MARS (our beloved MIPS simulator!) throughout this assignment. Feel free to read the attached documents (MARS Tutorial.pdf, MARS features.pdf) if you have not used MARS before or forgot about how to use it.

If you did not learn MIPS when you learned assembly language, please feel free to group with other students who have learned MIPS. You will pick it up easily with their help.

(Exercise) MIPS ↔ Machine Code

TPS (Think-Pair-Share) activity 1 Paired with the classmate(s) sitting next to you and perform the following tasks (You are allowed to form a group of three):

  1. Record the name(s) of your partner(s).
  2. Download MIPS_Reference_Sheet from CatCourses. We will need to refer to this sheet in order to complete all the exercises in this lab.
  3. Load s in MARS and study the code.
  4. After assembling the program, study the Text Segment window and see how your source code is translated into True Assembly Language (Basic) as well as machine code (Code).
  5. In true assembly language, every single instruction can be translated into a machine instruction. How many bits does a machine instruction contain?
  6. To utilize the limited number of bits efficiently, all machine instructions are categorized into different types (or formats). How many types are there? What are they? Give 2 operations for each type as examples.
  7. Now, locate the instruction in line #7 of s. Lets translate this instruction into machine code.
    1. What instruction type is this? How many fields does this type of instruction have? What are the names of these fields?
    2. Refer to the MIPS sheet, what is the value of the opcode of this instruction in Hex? What register is rs? What is the value of this register in Hex? What register is rt? What is the value of this register in Hex? What is the value of immediate in Hex?
    3. Construct the machine code of line #7 using the values obtained from part b. Write your answer in both binary and Hex You can verify your answer with the Code column in Text Segment window.
  8. Now, lets convert a machine code to a MIPS instruction. Locate address 0x00400010 from the Text Segment
    1. What is the machine code at this address in Hex? Convert this code into binary.
    2. From the binary version of this machine code. What is the instruction type? How can you tell? How many fields are there in this instruction type? What are the names of these fields?
    3. According to the binary machine code, what is the value of each field in Hex?
    4. Refer to the MISP sheet, what operation is this instruction? How can you tell? What is the mapping of the registers being used in this instruction?
    5. What is the final MIPS instruction? Is it the same as the Source column in the Text Segment window?
  9. Now, lets take a look at line #17 of s.
    1. What format is this instruction?
    2. What are the values of opcode, rs, and rt of this instruction in hex?
    3. What is the name of the target label if it takes the branch? What is the address of this label in hex? (Hint: you can find it in the Text Segment)
  1. So, do we put this address as the value of the immediate field of the instruction? Why?
  2. How do we find the value of the immediate field? What is this value?
  3. What is the machine code of this instruction in binary and hex formats? Does your answer match the Code column in the Text Segment window?
  1. Finally, lets convert the j instruction in line #20.
    1. What format is this instruction? How many fields are there in this format?
    2. What is the opcode of this instruction in hex?
    3. What label and address does this instruction jump to?
    4. How many bits can you use in the address field of the instruction? How can we squeeze the address into this field? What are the reasons behind this approach? What is the value of the address field in binary?
    5. What is the machine code of this instruction in binary and hex? Is it the same as whats in the Code column of the Text Segment window?

(Assignment 1, individual) Conversion in proc2.s

Convert the following line in proc2.s to machine code and then back to MIPS instructions: Line #7

Line #14

Line #17

Line #20

You must show all the steps including values of the instruction fields in order to receive points.

Verify your answers with the Text Segment window.

(Assignment 2, individual) Datapath

Trace through the paths the execution of SLTIU instruction in this single cycle datapath design. Fill in the appropriate control signal values in the table. If there are any modifications needs to make it work, draw them in the diagram and create appropriate control values.

(Signed or Zeros)

nPc_sel ExtOp ALUsrc ALUctr MemWr MemtoReg RegDst RegWr

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE140: Lab/HW #1 -Machine Language
$25