MIPS汇编 - 标签数值修改 [英] MIPS assembly - Label value modification

查看:446
本文介绍了MIPS汇编 - 标签数值修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在MIPS执行过程中更改标签的值,或者创建具有一定的价值标签?

Is it possible in MIPS to change during execution the value of a label, or to create a label with certain value?

我问这个,因为使用的指令时, LW $ A0,标签($ S0)我想每递增时间标签+4我们循环的值,表示阵列的新的存储器地址。我知道我能做到 LW $ A0,标签+ 4($ S0)标签,但的新值不会被保存。

I ask this because when using the instruction lw $a0, label($s0) i want to increment the value of label +4 every time we loop, indicating the new memory address of the array. I am aware I can do lw $a0, label+4($s0) but the new value of label will not be stored.

任何建议?

推荐答案

没有。在MIPS解引用(可怜的措辞)时,你必须有括号外的常数。如果它是可以改变标签的值,那么这将不再是恒定的。为了解决这个问题,你可以做,而不是像

No. In MIPS you must have a constant outside the parentheses when dereferencing (poor wording). If it were possible to change the value of the label, then it would no longer be constant. To get around this, you could instead do something like

la $t1, label          #t1 holds address of label
add $t1, $t1, $s0      #t1 now holds address of label + s0 offset
lw $a0, 0($t1)         #load word from t1's location

addi $t1, $t1, 4       #t1 was incremented by 4 bytes now
lw $a0, 0($t1)         #load the next word

有可能是建议使用阿杜如果S0将总是非负

It might be advisable to use addu if s0 will always be non-negative.

编辑:不能更改标签的值。它是专为在存储器中的位置的别名。在文本部分,它是下列指令的位置的别名。在数据部分中,这是在以下空间的存储器中的位置的别名。

You cannot change the value of a label. It is solely an alias for a location in memory. In the text section, it's an alias for the position of the following instruction. In the data section, it's an alias for the location in memory of the following space.

这篇关于MIPS汇编 - 标签数值修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆