0

I have an array a: .word 0:1000 and I don't understand how I can store/read values from it.

For example if I do sw $v0, a($s1) where $s1 is 0 it goes through fine but when I increment $s1 to supposedly access the next space in the array it gives me these errors.

Exception 5 [Address error in store] occurred and ignored
Exception 4 [Address error in inst/data fetch] occurred and ignored

edit: nvm I got it now :P

Edited by hwaforum: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Algorithm
0

Hi,
Her is the Answer :
.data
array: .space 256
length : word 256
newline: .asciiz "\n"
........
........
main:
move $t0, $zero
li $t1, 10
lw $t2, length
init :
sw $t1 array ($t0) # save the Value from $t1 in Array depending from Index $t0
addi $t0, $t0, 4 # increment Array-Index
addi $t1, $t1, 2
blt $t0, $t2 init

move $t0, $zero # initial and begin for Output
repeat:
li $v0, 1
lw $a0, array ($t0) # loading the Value from Array and put it out
syscall
addi $t0, $t0, 4

# print newline
li $v0, 4
la $a0, newline
syscall
blt $t0, $t2 repeat # if ($t0 value < $t2 value ) repeat

Viel Spaß

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.