我正在上我的第一堂建筑课,我得到了下面的代码片段来测试和学习。
不幸的是,当我运行该死的东西时,我收到了以下错误消息:
spim:(解析器)文件 /Users/X/Desktop/example_mips.asm .asciiz 第 2 行的未知字符“输入整数:” ^
现在鉴于这是一个课堂示例,我有点沮丧,它无法运行。
然而,我使用的是我自己的计算机,一台在 QtSpim 版本 9.1.16 上运行 OS X 10.10.1 的 Mac。
我们最初测试的学校计算机正在运行 Windows。这会有所作为吗?
有什么明显的错误吗?我假设这都是有效的代码:
.data
prompt: .asciiz “Enter in an Integer:”
str1: .asciiz “The answer is:”
newline:.asciiz “\n”
bye: .asciiz “Goodbye!\n”
.globl main
.text
main:
#init
li $s0, 10
#prompt for input
li $v0, 4
la $a0, prompt
syscall
#read in the value
li $v0, 5
syscall
move $s0, $v0
loop:
#print str1
li $v0, 4
la $a0, str1
syscall
#print loop value
li $v0, 1
move $a0, $s0
syscall
#print newline
li $v0, 4
la $a0, newline
syscall
#decrement loop value and branch if not negative
sub $s0, $s0, 1
bgez $a0, loop
#print goodbye message
li $v0, 4
la $a0, bye
syscall
#exit
li $v0, 10
syscall