在尝试存储用户输入的字符串时,对于项目的一部分,当我简单地加载文件时,我在 spim 中收到以下错误:
立即数对于字段来说太大:[0x0040009c]
下面是我的代码:
.globl main
.data
prompt: .asciiz "0: exit, 1: enter string, 2: convert, 3: mean, 4: median, 5: display string, 6: display array: " #94 char long
enter: .asciiz "Enter string: "
.text
main:
display: addi $v0, $v0, 4 #print prompt
lui $a0, 0x1000 #grabbing prompt
syscall
addi $v0, $0, 5 #get integer
syscall
beq $v0, 0, rtn #if user type's 0, exit program
nor $0, $0, $0 #nop
beq $v0, 1, enterString #if user type's 1, enterString
nor $0, $0, $0 #nop
enterString:
addi $v0, $0, 4 #printing string
lui $a0, 0x1000 #grabbing prompt
addi $a0, $a0, 95 #grabbing enter
syscall
addi $v0, $0, 8 #grabbing input
sw $a0, 0x10000100 #storing inpuit - this specific address is a requirement
syscall
rtn: jr $ra
现在,当我运行它时,我得到了上面提到的错误。但是,我不太清楚为什么。可能是因为字符串是 32 位的?任何关于为什么的解释将不胜感激。再次感谢!