| | |
Beginner SPIM Array help
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
I have an array
For example if I do
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
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.
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 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ß
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ß
![]() |
Similar Threads
- Fibonacci Series (C++)
- C++ beginner, vector<> or array[] ? (C++)
- sorting an 2d array (C++)
- accessing array declared within a class (C++)
- ARRAY (Visual Basic 4 / 5 / 6)
- 2-D array (C++)
- 2D-Array, switches, and importing from a file (C++)
- Creating an array/collection that holds variables (Visual Basic 4 / 5 / 6)
- organizing array output (Java)
- beginner (C++)
Other Threads in the Assembly Forum
- Previous Thread: An os whith a menu.
- Next Thread: Detect Multicore processors
| Thread Tools | Search this Thread |
3d access account append applet arc array arrays asm assembly binarysearchtree boot bootloader buttons byte c# c++ c/c++ cast char character class click compiler convert coordinates count counttheoccurenceofanintegerinthe10inputs data database delete draw dropdown dynamic file files frequency function garbage graph histogram image index input inputs int10h integer intersect java javascript jsp kernel language list listbox loops math memory menu multi multidimensional mysql number occurence output overwrite parameter parse perl php physics pointer program python random read recursion reference scanner search sequential shape split sql string strings table text transfer troubleshoot txt upload user values variable vb vbnet visualbasic.net visualstudio2008 x86






