0

I am trying to get this simple while loop to work. I'm using a textbook and I'm not sure what I'm missing cause I copied everything. only thing I added is the "main:" on top

main:
     sll $t1, $s3, 2
     add $t1,$t1,$s6
     lw $t0, 0($t1)
     bne $t0,$s5,Exit
 Loop: addi $s3,$s3, 1
     add $t1, $t1, 4
     lw $t0, 0($t1)
     beq $t0,$s5,Loop
 Exit:

I'm using QtSpim simulator and I'm getting the error an exception error as soon as the line is run "lw $t0, 0($t1)"

Aven
  • 1
  • 2
  • That can't possibly be the entire program. And without the rest of the code it's impossible to say what the problem is. – Michael Feb 12 '16 at 06:50
  • I'm using a book to write the code. So then I'm guessing the book is missing some things? What am I missing? – Aven Feb 13 '16 at 00:55
  • The code you've shown will attempt to read from some random location in memory, because neither `$s3` nor `$s6` has been initialized and yet you use them to calculate an address to read from. – Michael Feb 13 '16 at 08:46
  • that's what it was. thank you so much – Aven Feb 13 '16 at 21:43

0 Answers0