我的错误在哪里?2我需要打印所有大于零并被4除的数字。
它说:
(1)滑索32:0x0040000c处出现运行时异常:地址超出范围0x00000000
非常感谢
num1: .word -8 , num3
num2: .word 1998 , 0
num3: .word -9034 , num5
num4: .word -100 , num2
num5: .word 1972, num4
###############################code segment ###########################################################
.text
.globl main
main: #main program entry #load num1 from memory to $t0 (pesudo- instr)
secod:
la $t0,num1
li $a0,0
Secondloop:
lw $t1, 0($t0)
blt $t1 , $zero , notCount
lw $t0, 4($t0)
andi $t2 , $t1 , 3
beq $t2, $zero, theSecondCheck
j Secondloop
notCount:
lw $t0, 4($t0)
beq $t0,$zero,secondPrint
j Secondloop
theSecondCheck:
beq $t2,$zero,sum
j Secondloop
sum:
add $a0, $t1, $a0
j Secondloop
secondPrint: #print the result
li $v0,1
syscall
thirdLoop:
la $t0,num1
lw $t1, 0($t0)
lw $t0, 4($t0)
beq $t0,$zero,continuePrint
li $v0,11
bge $t1,$zero,printFourBase
li $a0, '-'
syscall
sub $t1,$zero,$t1
printFourBase:
li $t3,16
li $v0,1
continuePrint:
rol $t1,$t1,2
andi $a0,$t1,3
syscall
addi $t3,$t3,-1
bne $t3,$zero,Exit
j continuePrint
Exit:
li $v0,10
1条答案
按热度按时间s3fp2yjn1#
这是一个工作代码,我已经在过去: