如何解决为什么在火星上得到“无效的程序计数器值”?
我正在尝试将十六进制转换为整数,但是我一直收到此错误。
我以此为指南https://github.com/exercism/mips/blob/master/exercises/hexadecimal/example.mips
.data
getHex: .asciiz "Enter 32-bit hex: "
userInput: .space 8
hexvals: .word 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15
.text
li $v0,4 # put 4 in register $v0 in order to print whats in the address of $a0
la $a0,getHex # put the address of label getHex in $a0 in order for string with null to be printed
syscall
li $v0,8
la $a0,userInput
li $a1,9
syscall
hex_convert:
li $v0,0 # Reset accumulator to 0.
la $t0,hexvals # Load address of lookup into register.
loop:
lb $t1,0($a0) # Load a character,beq $t1,$zero,end # if it is null then return.
sll $v0,$v0,4 # Otherwise first shift accumulator by 4 to multiply by 16.
addi $t2,$t1,-48 # Then find the offset of the char from '0'
sll $t2,$t2,2 # in bytes,addu $t2,$t0 # use it to calcute address in lookup,lw $t3,0($t2) # retrieve its integer value,addu $v0,$t3 # and add that to the accumulator.
addi $a0,$a0,1 # Finally,increment the pointer
j loop # and loop.
end:
jr $ra
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。