我這裏有兩個問題:MIPS「LA」僞指令裝載文字的地址
1)>什麼是線2.「拉」僞指令發生的事情,而不是字面指加載地址,「3444 '應該有一個label.How它可以加載文字的地址
2)>如果你用「li $ a0 3444」替換第3行,它將3444加載到寄存器#a0而不是地址。輸出仍然是一樣的。我想問的是,系統調用如何知道在#a0中是變量的地址還是變量本身。打印整數的子程序如何正確工作,無論參數存儲在# a0是地址或整數值itse如果。
.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:我could'nt張貼在評論這樣的代碼...
IF LA(加載地址)和李(負載即時)都轉換爲相同的指令,即將文字加載到#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!"
無論如何,您不應該嘗試在註釋中張貼代碼。編輯澄清到你的答案是正確的事情要做。 –
標籤是地址。它們不是「存儲」在任何地方,它們只是象徵性地寫地址而不是數字地址的有用方法。 –