Reputation: 437
I have coded the program to get 4 values from user and store it. However I can't figure out how to put it into the 'list' (.space):
.data
list: .space 16
msg: .asciiz "Enter 4 numbers: "
.text
main:
la $a0,msg # display prompt string
li $v0,4
syscall
li $v0, 5 # read integer
syscall
add $s0, $v0, $zero #store input1 to s0
li $v0, 5 # read integer
syscall
add $s1, $v0, $zero #store input2 to s1
li $v0, 5 # read integer
syscall
add $s2, $v0, $zero #store input3 to s2
li $v0, 5 # read integer
syscall
add $s3, $v0, $zero #store input4 to s3
exit:
li $v0, 10 # exit system call
sysca
Upvotes: 1
Views: 23252
Reputation: 58507
I can't figure out how to put it into the 'list'
By loading the base address of the array into some register, and then using the sw
instruction to store data there:
la $a1, list
# ... read the integers ...
sw $s0, 0($a1)
sw $s1, 4($a1)
sw $s2, 8($a1)
sw $s3, 12($a1)
I suggest that you download MIPS32™ Architecture For Programmers Volume II: The MIPS32™ Instruction Set.
Upvotes: 8