Beginner SPIM Array help

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 1
Reputation: hwaforum is an unknown quantity at this point 
Solved Threads: 0
hwaforum hwaforum is offline Offline
Newbie Poster

Beginner SPIM Array help

 
0
  #1
Oct 21st, 2009
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
Last edited by hwaforum; Oct 21st, 2009 at 10:37 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: Algorithm is an unknown quantity at this point 
Solved Threads: 0
Algorithm Algorithm is offline Offline
Newbie Poster

SPIM-ARRAY

 
0
  #2
Nov 4th, 2009
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ß
Reply With Quote Quick reply to this message  
Reply

Tags
array, assembly

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC