确认使用商店字和加载字

时间:2015-12-09 03:05:28

标签: assembly

以下代码是否正确转换为汇编语言? c [i] = a [i] + b [i];假设我在$s0$s1,b在$s2,c在$s3

解决方案:

sll $t0, $s0, 2      #i*4
add $t0, $s1, $t0    #a[i]
lw $t0, 0($t0)

sll $t1, $s0, 2      #i*4
add $t1, $s2, $t1    #b[i]
lw  $t1, 0($t1)
add $t2, $t0, $t1    #a[i]+b[i]

sll $t3, $s0, 2      #i*4
add $t3, $s2, $t3    #c[i]
lw  $t3, 0($t3)      

sw $t2, 0($t3)      # store a[i]+b[i] into c[i]

请检查并确认。我最近开始学习汇编语言。这段代码对您来说可能很简单,我请求您帮助我。

0 个答案:

没有答案
相关问题