如何从 MIPS 汇编中的寄存器中获取单个字节?
How to get individual bytes from a register in MIPS assembly?
value: .asciiz "ABcd1234"
main:
lw $a0 value #Stores the value in a0
li $t0 0 #counter starts a 0
这样做给我:
$t0 = 0
$a0 = 64634241
我将如何获得 $t1 = 41
然后在另一个循环并将计数器递增 1 之后,得到 $t1 = 42 然后是 63 和 64 最后。
How would I go about getting $t1 = 41 and then after another loop and incrementing the counter by 1, get $t1 = 42 then 63 and 64 finally.
我假设你的意思是 0x64634241
、0x41
、0x42
、0x63
和 0x64
。
可以通过对值 0xff
执行按位与操作来隔离最低有效字节。在 MIPS 指令集参考中查找 andi
指令。
要获得下一个字节,您需要将整个字向右移动 8 位(查找 srl
指令),然后执行另一个“与”操作。等等。
value: .asciiz "ABcd1234"
main:
lw $a0 value #Stores the value in a0
li $t0 0 #counter starts a 0
这样做给我:
$t0 = 0
$a0 = 64634241
我将如何获得 $t1 = 41 然后在另一个循环并将计数器递增 1 之后,得到 $t1 = 42 然后是 63 和 64 最后。
How would I go about getting $t1 = 41 and then after another loop and incrementing the counter by 1, get $t1 = 42 then 63 and 64 finally.
我假设你的意思是 0x64634241
、0x41
、0x42
、0x63
和 0x64
。
可以通过对值 0xff
执行按位与操作来隔离最低有效字节。在 MIPS 指令集参考中查找 andi
指令。
要获得下一个字节,您需要将整个字向右移动 8 位(查找 srl
指令),然后执行另一个“与”操作。等等。