Tabrock
Tabrock

Reputation: 1169

Issues with MIPS jump

I'm still new to MIPS and I'm confused as to what is going wrong. Im testing in QTSpim. It's telling me "Unknown System Call:-1000". I'm a little confused as to whats going wrong. Im using -1000 in the console to jump into op to set my operand(building a simple integer calculator).

li $s7, 5   #Read a Character AS A INT and store in $s7
syscall

#Load values for each:
li $t0, 43 #Addition
li $t1, 45 #Subtraction
li $t2, 42 #Multiplication
li $t3, 47 #Division

#if $s7 is equal to any of these, then jump back to the main loop and wait for a second operand
beq $s7, $t0, loop #ADD
beq $s7, $t1, loop #SUB
beq $s7, $t2, loop #MULTI
beq $s7, $t3, loop #DIV

la $a0, error #Load error message
j ra

Upvotes: 0

Views: 683

Answers (1)

inherithandle
inherithandle

Reputation: 2664

Do you have a header that Qtspim should interpret Just as usual C code has the function main?

Here is MIPS header.

.globl main # Make main global so you can refer to
# it by name in QtSPIM.

.text # This line tells the computer this is the
# text section of the program
# (No data contained here).

main: # Program actually starts here.
// your code

ori $v0, $0, 10 # Sets $v0 to "10" so when syscall is executed, program will exit.
syscall # Exit.

So, your code should be:

.globl main # Make main global so you can refer to
# it by name in QtSPIM.

.text # This line tells the computer this is the
# text section of the program
# (No data contained here).

main: # Program actually starts here.
li $s7, 5   #Read a Character AS A INT and store in $s7


#Load values for each:
li $t0, 43 #Addition
li $t1, 45 #Subtraction
li $t2, 42 #Multiplication
li $t3, 47 #Division

#if $s7 is equal to any of these, then jump back to the main loop and wait for a second operand
beq $s7, $t0, loop #ADD
beq $s7, $t1, loop #SUB
beq $s7, $t2, loop #MULTI
beq $s7, $t3, loop #DIV

la $a0, error #Load error message
j ra


ori $v0, $0, 10 # Sets $v0 to "10" so when syscall is executed, program will exit.
syscall # Exit.

Upvotes: 1

Related Questions