我只是试图从控制台的输入中读取字符串。我正在运行xspim来模拟,但是需要这个在裸模式下运行,这意味着我不能使用伪指令,并且我在网上找到的很多东西都是用和伪指令来完成的。在我正在阅读的所有文档中,它说使用“la”指令将字符串存储在$ a0中,但是该指令不适用于我们。我读到了那条指令的意思,并且有效地变成了一个“lui”,然后是一个“ori”。抛出我的部分是我们应该输入第一个数据位置(始终为0x 1000 0000)和字符串中第一个字节的地址之间的字节数。我不确定我的字符串的第一个字节是什么。下面是我有:对于RISC机器如何获取在裸机模式下运行的MIPS中的静态数据的地址(不是伪指令)
.globl main
.globl done
.globl convert
.data
prompt: .asciiz "Enter a decimal number, to quit type 'quit':" #45
result: .asciiz "The number you entered is " #72
input: .space 64
.text
convert:
main: addi $v0, $0, 4 #Print prompt to enter number
lui $a0, 0x1000 #Address of prompt
syscall #Display prompt
addi $v0, $0, 8 #Setting up syscall to read in string
lui $at, 4097
ori $a0, $at, input #Where I want my string to be stored
addi $a1, $0, 64 #How long my string will be
syscall #Syscall to read in string
您可以通过使用堆栈上的缓冲区(用于输入缓冲区)来解决该问题。 –