What is the single MIPS instruction or the shortest sequence of MIPS instruction
ID: 3665199 • Letter: W
Question
What is the single MIPS instruction or the shortest sequence of MIPS instructions that performs:
a. clears a word at memory location 524,298
b. y[30] = y[40] + x, assuming x corresponds to register R9, and y is an array of integers with y[0] an integer at the memory location 1,048,596
c. x = y * w, assuming x, y, and w are integer variables in memory locations 4000,2000, and 3004, respectively.
d. if (x => y) Goto lab1
Assume that variable x corresponds to a word at memory address 800, and variable y corresponds to a word at memory address 1000. The instruction with lab1 is after the branch instruction and there are 30 instructions between those two instructions.
Explanation / Answer
Solution:
lui stands for load upper immediate
a.
Move content of register r10 into register r22.
add r22,r0,r10
Load registers r15 with the value 524,298
lui r15, 4
addi r15, r15, 1
Store the value 49,153 into a word at memory location 1,048,596
ori r15, r0, 0b1100000000000001
sw r15, 1,048,596 (r0)
b.
Load the instruction in register r8.
Add values
Store the values in r8 register.
lui r1, 8 r1 <- &y[0]
lw r8, 40(r1)
add r8, r8, r9
sw r8, 30(r1)
c.
Load the instruction in register r1.
Load the instruction in register r2.
Multiply values of register r1 and r2
Store the value in register r1.
lw r1, 2000(r0) r1 <- y
lw r2, 3004(r0) r2 <- w
mul r1, r2
mflo r1
sw r1, 4000(r0)
d.
Load the instruction in register r30
lw r30,800(0)
slt r1, r10, r30
beq r1, r0, -29
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.