2016-09-20 2 views
0

내 코드는 지원되지 않는 R-Type으로 표시됩니다. 올바르게 빼는 방법은 무엇입니까? 안에서 다른 세부 정보를 변경하려고 시도했습니다 ... 이미 잠을 사용하여 시도했습니다 ..................................... .................................................. ........MIPS- 빼는 방법 (이미 사용중인 하위가 작동하지 않습니다!)

.data 
 
str: .asciiz "\nHello World!\n" 
 
# You can change what is between the quotes if you like 
 

 
.text 
 
.globl main 
 

 
main: 
 
# Do the addition 
 
# For this, we first need to put the values 
 
# to add into registers ($t0 and $t1) 
 
li $t0, 30 # You can change the 10 
 
li $t1, 20 # You can change the 20 
 

 
# Now we can add the values in $t0 
 
# and $t1, putting the result in special register $a0 
 
sub $a0, $t0, $t1 
 

 
# Set up for printing the value in $a0. 
 
# A 1 in $v0 means we want to print an int 
 
li $v0, 1 
 

 
# The system call looks at what is in $v0 
 
# and $a0, and knows to print what is in $a0 
 
syscall 
 

 
# Now we want to print Hello World 
 
# So we load the (address of the) string into $a0 
 
la $a0, str 
 

 
# And put a 4 in $v0 to mean print a string 
 
li $v0, 4 
 

 
# And just like before syscall looks at 
 
# $v0 and $a0 and knows to print the string 
 
syscall 
 

 
# Nicely end the program 
 
li $v0, 0 
 
jr $ra

답변

1

귀하의 프로그램은 marsspim 시뮬레이터 프로그램 종료에 대한 제외 에서 잘 실행됩니다. 이 시뮬레이터는 $ra을 설정하지 않으므로 0입니다. 결국, 당신은 불법적 인 것을 포함하여 세미 무작위 지시를 할 수있는 무언가로 돌아가고 있습니다. 따라서 이 아닌sub이 문제가됩니다. 나중에 일어나는 일입니다.

변경 :

# Nicely end the program 
li $v0, 0 
jr $ra 

속으로 :

# Nicely end the program 
li $v0, 10 
syscall 
관련 문제