| | |
Question about arrays
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
I'm writing a program that takes input for an an array. It then uses a loop to replace the values in another array that has preset values with the values from the array that received input.
When I try to move the values though...well let's say arrayA is the one with the preset values and arrayB is the one that has the inputted values. lw $t3, arrayB($t0) - yields an error, but lw $t3, arrayA($0) works. Is there another command that needs to be used when getting the value from an array that doesn't have preset content?
I know it's very basic, but I don't know if I'm missing a command or something. Using PCSpim.
And also the number replacement will be done with a loop hence why I'm using arrayB($t0) instead of something else...if that makes any sense at all.
When I try to move the values though...well let's say arrayA is the one with the preset values and arrayB is the one that has the inputted values. lw $t3, arrayB($t0) - yields an error, but lw $t3, arrayA($0) works. Is there another command that needs to be used when getting the value from an array that doesn't have preset content?
assembly Syntax (Toggle Plain Text)
.data strOutput: .asciiz "Input: " arrayA: .word 1,2,3,4 arrayB: .space 16 .text .globl main main: li $v0, 4 la $a0, strOutput syscall la $t1,arrayB li $v0, 8 la $a0, 0($t1) syscall li $v0, 8 la $a0, 4($t1) syscall li $v0, 8 la $a0, 8($t1) syscall li $v0, 8 la $a0, 12($t1) syscall li $t0, 0 lw $t3, arrayB($t0)
I know it's very basic, but I don't know if I'm missing a command or something. Using PCSpim.
And also the number replacement will be done with a loop hence why I'm using arrayB($t0) instead of something else...if that makes any sense at all.
Last edited by zmwg; Oct 18th, 2009 at 9:00 pm.
1
#2 Oct 19th, 2009
I think you misunderstand the syscall function. It doesn't return a four byte integer. It returns a string!
You also aren't setting $a1 to maximum number of characters to read - 1. The function returns the string with a NULL terminaton.
$a0 = buffer
$a1 = sizeof buffer - 1
$v0 = 8 Function read string.
think you meant $v0 = 5 ? Upon return $v0 contains integer read!
You also aren't setting $a1 to maximum number of characters to read - 1. The function returns the string with a NULL terminaton.
$a0 = buffer
$a1 = sizeof buffer - 1
$v0 = 8 Function read string.
think you meant $v0 = 5 ? Upon return $v0 contains integer read!
Last edited by wildgoose; Oct 19th, 2009 at 12:35 am.
![]() |
Similar Threads
- Quick help with printing arrays (Java)
- Arrays in Family class (Java)
- Some questions about arrays (Java)
- Question about arrays (JavaScript / DHTML / AJAX)
- compare 2D arrays (C++)
- Newbie Problem: Arrays (C++)
- Question on arrays & methods (Java)
- array question (C++)
Other Threads in the Assembly Forum
- Previous Thread: need help how about assebly error
- Next Thread: EMU8086 OS Command Comparison
| Thread Tools | Search this Thread |





