MIPS "la" 伪指令加载文字地址
MIPS "la" pseudo instruction loads a literal's address
我这里有两个问题:
1)> 2.The 行发生了什么 'la' 伪指令是指加载地址,而不是文字 '3444' 应该有一个 label.How 可以加载吗文字的地址
2)> 如果你用 "li $a0 3444" 替换第 3 行,它将 3444 加载到寄存器 #a0 而不是 address.The 输出仍然是 same.What 我想从这里问系统调用如何知道 #a0 中是变量的地址或变量 itself.How 打印整数的子例程能否正常工作,无论存储在 #a0 中的参数是地址还是整数值本身。
.text
li $v0 1
>>2 la $a0 3444 # When i replace 3444 literal with the label 'anint' it makes sense and the output of course is the same
syscall
.data
anint: .word 3444
输出:
3444
更新#2:我不能post评论中的代码所以...
IF la(load address) 和 li(load immediate) 都转换为相同的指令,即将文字加载到 #a0 中,然后从下面的代码段解释第 3 行。
.text
li #v0 4
>>3 la #a0 msg #This loads the address of the label 'msg in #a0' not the label itself
syscall
.data
msg: .asciiz "This is a long string that can't be saved in the register!"
how could syscall know that in #a0 is the address of the variable or the variable itself
没有。 SPIM/MARS 中的系统调用 1 始终在 $a0
.
中打印 value
li $a0,3444
和la $a0,3444
被翻译成同一个东西(一些将值3334
加载到寄存器$a0
的指令,例如ori $a0, [=15=], 3334
) .
我这里有两个问题:
1)> 2.The 行发生了什么 'la' 伪指令是指加载地址,而不是文字 '3444' 应该有一个 label.How 可以加载吗文字的地址
2)> 如果你用 "li $a0 3444" 替换第 3 行,它将 3444 加载到寄存器 #a0 而不是 address.The 输出仍然是 same.What 我想从这里问系统调用如何知道 #a0 中是变量的地址或变量 itself.How 打印整数的子例程能否正常工作,无论存储在 #a0 中的参数是地址还是整数值本身。
.text
li $v0 1
>>2 la $a0 3444 # When i replace 3444 literal with the label 'anint' it makes sense and the output of course is the same
syscall
.data
anint: .word 3444
输出:
3444
更新#2:我不能post评论中的代码所以...
IF la(load address) 和 li(load immediate) 都转换为相同的指令,即将文字加载到 #a0 中,然后从下面的代码段解释第 3 行。
.text
li #v0 4
>>3 la #a0 msg #This loads the address of the label 'msg in #a0' not the label itself
syscall
.data
msg: .asciiz "This is a long string that can't be saved in the register!"
how could syscall know that in #a0 is the address of the variable or the variable itself
没有。 SPIM/MARS 中的系统调用 1 始终在 $a0
.
li $a0,3444
和la $a0,3444
被翻译成同一个东西(一些将值3334
加载到寄存器$a0
的指令,例如ori $a0, [=15=], 3334
) .