简体   繁体   English

计算标签地址

[英]Calculating address of labels

I am stuck with solving my assignment.我坚持解决我的任务。 Here is what it states,这是它所说的,

Consider the following fragment of MIPS assembly-language code:考虑以下 MIPS 汇编语言代码片段:

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? a) 如果 label start 的值为 100(所有数字均为十进制),标签 middle、q_final 和 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.我在想,每条语句加 4 会给出其他标签的值。 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.我在想,每条语句加 4 会给出其他标签的值。 Is there another better way of doing this?还有另一种更好的方法吗?

Simpler is better (mips.), If each instruction takes 4 bytes.越简单越好(mips.),如果每条指令占用 4 个字节。 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?对了,谁给出了十进制的memory地址?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM