Memory Out of bound error

2.8k views Asked by At

Possible Duplicate:
Compile time initialized array error

I am trying to load data from a compiled time initialized array. But when I try to load the data, I get "Memory OUt of bound error". Here is the code:

.data

array: .space 'A','B','C','D','E','F','G','H','I'

.text

 main:
 .
 .
 .

 la $t0,array

# $t1 is intialized to 0 and then incremented in code later for next loading
add $s4,$t1,$t0

 lb $a0,0($s4) # Here is error "Memory out of bound"

 li $v0,4

 syscall

How can I solve this issue? I am using QTSpim

Regards

1

There are 1 answers

4
Patrik On

.space reserves empty space, without data in it. You should use:

.asciiz "ABCDEFGHI"