I am stuck with solving my assignment. Here is what it states,
Consider the following fragment of MIPS assembly-language cod开发者_开发问答e:
start: add $t1, $t2, $t3
addi $t1, $t1, 10
add $t4, $t2, $t2
add $t6, $t3, $t3
beq $t1, $t4, q_final
middle: add $t1, $0, $0
bne $t6, $t4, s_final
add $t7, $t7, $t7
j final
q_final: slt $t1, $t4, $t6
s_final: add $t7, $t7, $t1
final: jr $ra
a) If the label start has the value 100 (all numbers in decimal notation), what are the addresses specified by labels middle, q_final and final? I am confused with how to proceed. I was thinking that adding 4 to each statement would give the value of the other labels. Is there another better way of doing this?
Thanks in advance.
I am confused with how to proceed. I was thinking that adding 4 to each statement would give the value of the other labels. Is there another better way of doing this?
Simpler is better (mips!). If each instruction takes 4 bytes, then that´s preety much it.
100: add $t1, $t2, $t3
104: addi $t1, $t1, 10
108: add $t4, $t2, $t2
112: add $t6, $t3, $t3
116: beq $t1, $t4, 132
120: add $t1, $0, $0
124: bne $t6, $t4, 136
128: add $t7, $t7, $t7
132: slt $t1, $t4, $t6
136: add $t7, $t7, $t1
140: jr $ra
By the way, who gives memory addresses in decimal notation?
精彩评论