我正在使用PCSpim,我有一个问题,我有一个字符数组插入十六进制数的值,称之为HEXARRAY。
.byte '0','0','0','0','0','0','0',‘0’,‘0’,‘0’,‘0’,‘0’,'0'.
我想通过以下操作插入一个整数
sb $t0,十六进制($t1)
其中$t0是我想要的int,比方说8,而$t1是8,数组中的最后一个字节。
int在MIPS中有4个字节,如何将int插入到1字节?
发布于 2016-10-08 22:35:42
您可以通过执行'sw‘=存储字来插入一个单词(32位).类似于:
number: .word 8 # your number is 8
space: .space 20 # adress to save your number
la $t3, number # loading the adress of your number 8
lw $t3, 0($t3) # NOTICE that with 'lw' you are taking your WHOLE WORD = number 8
la $s1, space
sw $t3, 0($s1) # where $t3 is your number and $s1 the adress you want to save it如果您不想保存整个数字8,但是要保存数字的单独字节.你可以在$s1的不同的广告中这样做。
类似于:
sb $t3, 0($s1) # you are storing the byte'00001000' in the 1st adress of $s1
addi $s1, $s1, 1 # adding 1 to the adress where you want to save your next byte
srl $t3, $t3, 3 # moving your number 8 (in binary) to the right... so you can
# 'sb' = store byte (a different one) again in $s1https://stackoverflow.com/questions/39933427
复制相似问题