For the following MIPS programming exercise, you may use only these instructions
ID: 3883612 • Letter: F
Question
For the following MIPS programming exercise, you may use only these instructions or macros:
add addi addiu addu and andi div divu li lui lw mfhi mflo mult multu nor or ori sll sra srl sub subu sw xor xori
Initialize register $9 to 0x7000. Shift the bit pattern so that $9 contains 0x70000000. Now use the addu instruction to add $9 to itself. Is the result correct?
Then repeat the procedure using register $10 and the add instruction. What happens?
Write a short description (2 or 3 sentences is enough) of the differences.
Explanation / Answer
First let us find the instructions to use
1. ori: To load a constant into a register
2. addu: This will help in adding two registers and storing the result in register
3.sll: This places result in third register by shifting left the register with shift amount
4. add; This will add two registers data and stoes in register
ori $9, $0, 0x7000 # This willinitialize $9 to 0x7000
sll $9, $9, 16 # This will shift left logical by 4 zeros
addu $9, $9, $9
This will add $9 to itself
ori $10, $0, 0x7000 # This willinitialize $9 to 0x700
sll $10, $10, 16 # This will shift left logical by 4 zeros
add $10, $10, $10
This will add $9 to itself