【发布时间】:2021-09-29 21:50:56
【问题描述】:
我在第 19 行收到一个错误,说 blt 未知错误。我真的不太了解 MIPS 处理器
.data
A: .word 4,8,12,16,20,24,28
Message: .ascii " The Sum is:"
.text
li $t0,0 # load immediate value 0 to regiter $t0
li $t1,7 # load immediate value 7 to regiter $t1
li $t3,2 # load immediate value 2 to regiter $t3
la $t2,A # load address of array to regiter $t2
li $s0,0 # load immediate value 0 to regiter $so to hold sum value
calSum:
div $t5,$t0,$t3 # Divide $t0 with $t1 and store result in $t2
mfhi $t4 # remainder to $t4
bnez $t4,X2 # If remainder is not zero then jump to label X2
lw $t6,0($t2) # Store zeroth element of array register $t6
add $s0,$s0,$t6 # Add this to sum in register $s0
X2:
addi $t2,$t2,4 # If index is not divisible by 2 then point to next element
addi $t0,$t0,1 # Increment index
blt $t0,$t1,calSum # Repeat from label calSum
li $v0, 4 # To print message use system call
la $a0, Message
syscall
move $a0,$s0 # print result stored in register $s0
li $v0,1 # System call to print number in register $ao
syscall
li $v0, 10 # System call to exit to DOS
syscall
【问题讨论】:
-
第 19 行是哪一行?
-
什么工具链/汇编器?
-
很抱歉我把编辑历史弄得一团糟。我正在编辑问题,其他人也在同一时间我们必须同时点击保存,因为我的编辑同时显示了我的更改和其他人的编辑(比如将 blt 更改为 ble,这没有意义因为它使问题无效)。所以我回滚了包含我们两个更改的编辑,但我之前从未使用过回滚,所以一开始我做错了,有点乱......
-
@JerryJeremiah:别担心,伙计,我想我们会挺过去的!
标签: assembly mips instructions