Trying to run this code in MIPS and i am getting an error saying "Runtime exception at 0x00400090: address out of range 0x00000008"

0
.text
main: #Main function to be run
la $a0, prompt

li $v0, 4
syscall


la $a0, n0


li $a1, 8

li $v0, 8
syscall
move $t0, $v0

la $a0, n1
li $a1, 8
li $v0, 8
syscall
move $t1, $v0

la $a0, n2
li $a1, 8
li $v0, 8
syscall
move $t2, $v0

la $a0, n3

li $a1, 8

li $v0, 8
syscall
move $t3, $v0


la $a0, n4

li $a1, 8

li $v0, 8
syscall
move $t4, $v0

#Outputs
la $a0, ($t0)

li $v0, 8
syscall

la $a0, ($t1)

li $v0, 8
syscall

la $a0, ($t2)

li $v0, 8
syscall

la $a0, ($t3)

li $v0, 4
syscall

la $a0, ($t4)

li $v0, 4
syscall



li $v0, 10
syscall




.data
prompt: .asciiz "Enter a series of 5 formulae:\n" #The prompt to ask the user to type 5 strings
n0: .space 20
n1: .space 20
n2: .space 20
n3: .space 20
n4: .space 20
range
mips
outofrangeexception
asked on Stack Overflow Sep 29, 2020 by duge007 • edited Sep 29, 2020 by John Ledbetter

1 Answer

0

Here's what to do:

Find out what line of your assembly code corresponds to 0x00400090 — or the address of the exception.  That is the specific instruction that is getting the fault.  Then look for inputs to that instruction that are incorrect (i.e. here, that have value 0x00000008, and fix the code so that register has a proper address).

You can do this in the MARS simulator.  When it reports the exception, have a look at the excepting instruction, and check the register values at that point.  If you want you can also set a breakpoint on or just before the excepting instruction, and re-run it so you can see the register state as it evolves prior to the exception.

answered on Stack Overflow Sep 29, 2020 by Erik Eidt • edited Sep 29, 2020 by Erik Eidt

User contributions licensed under CC BY-SA 3.0