[英]C to MIPS assembly language
i
and j
are assigned to registers $s3
and $s4
and the base address of A
and B
are in registers $s6
and $s7
. i
和j
分配给寄存器$s3
和$s4
, A
和B
的基地址位于寄存器$s6
和$s7
。
B [8] = A [i-j]
So the answer is something like 所以答案是这样的
sub $t0, $s3, $s4
add $t0, $s6, $t0
lw $t1, 16($t0) (What is happening here.. I am so confused)
sw $t1, 32($s7)
Please explain. 请解释。 I am so confused 我感到很困惑
My MIPS assembly is rusty, but... 我的MIPS组件生锈了,但是...
lw/sw are load word/store word. lw / sw是加载字/存储字。
syntax being lw register, address 语法为lw寄存器,地址
So for the instruction you indicated, the address in $t0 is being loaded into $t1. 因此,对于您指示的指令,$ t0中的地址正在加载到$ t1中。 The 16 thing is a notation to add 16 to $t0 before the load word instruction. 16表示在加载字指令之前将16加到$ t0。
The code looks incorrect: 该代码看起来不正确:
sub $t0, $s3, $s4 # t0 = i -j
# there should be a "sll $t0, 2" here to convert i-j to a byte offset
add $t0, $s6, $t0 # t0 += &A
lw $t1, 16($t0) # this line is incorrect - it should be lw t1,($t0) with no offset
sw $t1, 32($s7) # store t1 at &B + 8 words i.e. 32 bytes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.