为什么我会收到此程序的 MIPS 语法错误?
Why do I get a MIPS syntax error for this program?
我有这个简单的程序来打印我的名字,但是当我 assemble 它时,它说第一行包含语法错误。我很确定我已经正确地写了开场白,所以我不确定为什么。当我在在线模拟器上 运行 它说 "Syntax error" 而在我的计算机上的 QTSPIM 模拟器上“指令引用 0x00400014 处的未定义符号
[0x00400014] 0x0c000000 jal 0x00000000 [主] ; 188: 主航道
.text
main:
li $v0, 11 #Load command to print characters in v0 register
la $a0, 64 #Load character '@' into 4 register
syscall
sub $v0, 10 #Subract from v0 to get 1, command to print integers
sub $a0, 64 # sub from to print 0
syscall
addi $a0, 49, $zero #Make 4 register store 1
syscall
addi $a0, 6, $zero #Make 4th register store 6
syscall
sub $a0, 5 #Make 4th register store 1
syscall
addi $a0, $zero, 6 #Make 4th register store 7
syscall
sub $a0, 3 #Make 4th register store 4
syscall
syscall
addi $a0, $zero, 4 #Make 4th register store 8
syscall
addi $v0, 10 #Print out char again
sub $a0, 46 #Print out new line (ASCII 10)
syscall
addi $a0, $zero, 56 #Store 'B'
syscall
addi $a0, $zero, 42 #Store 'l'
syscall
sub $a0, 11 #Store 'a'
syscall
addi $a0, $zero, 2 #Store 'c'
syscall
addi $a0, $zero, 8 #Store 'k'
syscall
sub $a0, 64 #Store ','
syscall
sub $a0, 12 #Store space ' '
syscall
addi $a0, $zero, 52 #Store 'T'
syscall
addi $a0, $zero,27 #Store 'e'
syscall
addi $a0, $zero, 13 #Store 'r'
syscall
sub $a0, 13 #Restore 'e'
syscall
addi $a0, $zero, 7 #Store 'l'
syscall
sub $a0, 98 #Start new line
syscall
sub $v0, 1 #Store exit commmand in v0
syscall
首先,您需要整理和识别您的代码,这会对您有所帮助。
其次,代码中存在语法错误:
必须如何:(我从火星软件中得到这个。)
sub $t1,$t2,$t3 Subtraction with overflow : set $t1 to ($t2 minus $t3)
addi $t1,$t2,-100 Addition immediate with overflow : set $t1 to ($t2 plus signed 16-bit immediate)
而且我真的不明白你想打印什么。为什么你对v0做多次操作而不是直接设置它的值?
我修改了你的代码来打印
@0161748
Black, Terel
这就是我所理解的你想要的。如果是其他原因,请将您的评论编辑得更具体。
.text
main:
li $v0, 11 #Load command to print characters in v0 register
la $a0, 64 #Load character '@' into 4 register
syscall
sub $v0, $v0, 10 #Subract from v0 to get 1, command to print integers
sub $a0, $a0, 64 # sub from $a0 to print 0
syscall
addi $a0, $zero, 1 #Make 4 register store 1
syscall
addi $a0, $zero, 6 #Make 4th register store 6
syscall
sub $a0, $a0, 5 #Make 4th register store 1
syscall
addi $a0, $a0, 6 #Make 4th register store 7
syscall
sub $a0, $a0, 3 #Make 4th register store 4
syscall
addi $a0, $a0, 4 #Make 4th register store 8
syscall
addi $v0, $v0, 10 #Print out char again
addi $a0, $zero, 10 #Print out new line (ASCII 10)
syscall
addi $a0, $zero, 66 #Store 'B'
syscall
addi $a0, $zero, 108 #Store 'l'
syscall
addi $a0, $zero, 97 #Store 'a'
syscall
addi $a0, $zero, 99 #Store 'c'
syscall
addi $a0, $zero, 107 #Store 'k'
syscall
addi $a0, $zero, 44 #Store ','
syscall
addi $a0, $zero, 32 #Store space ' '
syscall
addi $a0, $zero, 84 #Store 'T'
syscall
addi $a0, $zero, 101 #Store 'e'
syscall
addi $a0, $zero, 114 #Store 'r'
syscall
addi $a0, $zero, 101 #Restore 'e'
syscall
addi $a0, $zero, 108 #Store 'l'
syscall
sub $a0, $a0, 98 #Start new line
syscall
sub $v0, $v0, 1 #Store exit commmand in v0
syscall
我有这个简单的程序来打印我的名字,但是当我 assemble 它时,它说第一行包含语法错误。我很确定我已经正确地写了开场白,所以我不确定为什么。当我在在线模拟器上 运行 它说 "Syntax error" 而在我的计算机上的 QTSPIM 模拟器上“指令引用 0x00400014 处的未定义符号 [0x00400014] 0x0c000000 jal 0x00000000 [主] ; 188: 主航道
.text
main:
li $v0, 11 #Load command to print characters in v0 register
la $a0, 64 #Load character '@' into 4 register
syscall
sub $v0, 10 #Subract from v0 to get 1, command to print integers
sub $a0, 64 # sub from to print 0
syscall
addi $a0, 49, $zero #Make 4 register store 1
syscall
addi $a0, 6, $zero #Make 4th register store 6
syscall
sub $a0, 5 #Make 4th register store 1
syscall
addi $a0, $zero, 6 #Make 4th register store 7
syscall
sub $a0, 3 #Make 4th register store 4
syscall
syscall
addi $a0, $zero, 4 #Make 4th register store 8
syscall
addi $v0, 10 #Print out char again
sub $a0, 46 #Print out new line (ASCII 10)
syscall
addi $a0, $zero, 56 #Store 'B'
syscall
addi $a0, $zero, 42 #Store 'l'
syscall
sub $a0, 11 #Store 'a'
syscall
addi $a0, $zero, 2 #Store 'c'
syscall
addi $a0, $zero, 8 #Store 'k'
syscall
sub $a0, 64 #Store ','
syscall
sub $a0, 12 #Store space ' '
syscall
addi $a0, $zero, 52 #Store 'T'
syscall
addi $a0, $zero,27 #Store 'e'
syscall
addi $a0, $zero, 13 #Store 'r'
syscall
sub $a0, 13 #Restore 'e'
syscall
addi $a0, $zero, 7 #Store 'l'
syscall
sub $a0, 98 #Start new line
syscall
sub $v0, 1 #Store exit commmand in v0
syscall
首先,您需要整理和识别您的代码,这会对您有所帮助。
其次,代码中存在语法错误:
必须如何:(我从火星软件中得到这个。)
sub $t1,$t2,$t3 Subtraction with overflow : set $t1 to ($t2 minus $t3)
addi $t1,$t2,-100 Addition immediate with overflow : set $t1 to ($t2 plus signed 16-bit immediate)
而且我真的不明白你想打印什么。为什么你对v0做多次操作而不是直接设置它的值?
我修改了你的代码来打印
@0161748
Black, Terel
这就是我所理解的你想要的。如果是其他原因,请将您的评论编辑得更具体。
.text
main:
li $v0, 11 #Load command to print characters in v0 register
la $a0, 64 #Load character '@' into 4 register
syscall
sub $v0, $v0, 10 #Subract from v0 to get 1, command to print integers
sub $a0, $a0, 64 # sub from $a0 to print 0
syscall
addi $a0, $zero, 1 #Make 4 register store 1
syscall
addi $a0, $zero, 6 #Make 4th register store 6
syscall
sub $a0, $a0, 5 #Make 4th register store 1
syscall
addi $a0, $a0, 6 #Make 4th register store 7
syscall
sub $a0, $a0, 3 #Make 4th register store 4
syscall
addi $a0, $a0, 4 #Make 4th register store 8
syscall
addi $v0, $v0, 10 #Print out char again
addi $a0, $zero, 10 #Print out new line (ASCII 10)
syscall
addi $a0, $zero, 66 #Store 'B'
syscall
addi $a0, $zero, 108 #Store 'l'
syscall
addi $a0, $zero, 97 #Store 'a'
syscall
addi $a0, $zero, 99 #Store 'c'
syscall
addi $a0, $zero, 107 #Store 'k'
syscall
addi $a0, $zero, 44 #Store ','
syscall
addi $a0, $zero, 32 #Store space ' '
syscall
addi $a0, $zero, 84 #Store 'T'
syscall
addi $a0, $zero, 101 #Store 'e'
syscall
addi $a0, $zero, 114 #Store 'r'
syscall
addi $a0, $zero, 101 #Restore 'e'
syscall
addi $a0, $zero, 108 #Store 'l'
syscall
sub $a0, $a0, 98 #Start new line
syscall
sub $v0, $v0, 1 #Store exit commmand in v0
syscall