Question

Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of...

Question 1. Answer the following questions on MIPS Instruction Set.
a) Show the minimal sequence of MIPS instruction for the following pseudocode segment:

A[3] = A[10] + B;

Assume that B corresponds to register $t3 and the array A has a base address of 1000C41016 which is required to be loaded to register $t0 in your code. Provide comments for each line of your MIPS instruction.

b) Assume that Loop starts at memory location 0xC010. Provide a) instruction format of each MIPS instruction, b) encode each MIPS instruction into hexadecimal format and c) show each instruction field. Use the reference shown in Page 7 and 8, or MIPS Reference Data Green Card.

Loop :

sub $t3, $t1, $t2

lw $s2, 4($t3)

bne $s0, $s2, Exit

j Loop

Exit: …

Homework Answers

Answer #1

(a)
A[3] = A[10] + B;

lw $t1, 40($t0)       //$t1 = A[10]
add $t1, $t1, $t3   //$t1 = A[10] + B
sw $t1, 12($t0)       // A[3] = A[10] + B

(b)
sub $t3, $t1, $t2
R-format

opcode       rd           rs   rt   shamt      funct
000000   01001   01010   01011   00000   100010

Hexadecimal = 0x012A5822
-------------------------------------------------------------------------------
lw $s2, 4($t3)
I-format

opcode        rs           rt               offset
100011   01011   10010   0000000000000100

Hexadecimal = 0x8D720004
-------------------------------------------------------------------------------
bne $s0, $s2, Exit
I-format
offset = 1

opcode      rs            rt              offset
000101   10000   10010   0000000000000001

Hexadecimal = 0x16120001
-------------------------------------------------------------------------------
j Loop
J-type
Address of Loop = 0xC010 (1100 0000 0001 0000)
right shift (1100 0000 0001 0000) by 2 bit
Target = 0011 0000 0000 0100

opcode            target
000010   00000000000011000000000100

Hexadecimal = 0x08003004

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
This is a homework assignment for Computer Architecture and some question use MIPS Assembly language. 1.    ...
This is a homework assignment for Computer Architecture and some question use MIPS Assembly language. 1.     In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x1fff0000. Loop: sw $t1, 4($s0)        addi $t1, $t1, -1    sll $t1, $t1, 2        bne $t1, $s5, Exit    addi $s0, $s0, 4          j Loop Exit: … 2.     Find the MIPS...
Encode the following instruction (1) identify the instruction format that will be used, (2) indicate the...
Encode the following instruction (1) identify the instruction format that will be used, (2) indicate the values of each of the fields for that format in decimal, (3) convert each of these decimal val- ues to binary 4) represent the entire instruction as one hexadecimal value. subu $t3,$v1,$s2
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022 ori $t0, $t0, 2048 srl $t1, $t0, 18 sw $t0, 101($t1) slti $t2, $t1, 5 beq $t2, $0, label3 label2:... ... label3:... a) The code modifies a word in memory at the following address (circle one): (i) 1022 (ii) 101 (iii) 5 (iv) 10220000 (v) Other (provide your own answer): _________________ b) The following value is stored in memory (circle one): (i) 0x17 (ii)...
Answer the following questions in question/answer format. Questions 1-3, you should show calculations on how you...
Answer the following questions in question/answer format. Questions 1-3, you should show calculations on how you calculated your final answer. Each question is worth 2 points. 1. An infectious disease broke out in a village where men and women were given different medications. All infected persons had to go to the clinic to get injections once a day. Men were prescribed medication “A” which costs $400. Women were prescribed medication “B” which costs $150. The cost to administer the medication...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT