Reputation: 83
I want take 8 inputs and create two 2X2 arrays in assembly. However when i run it it only asks me for a(1,1)a(1,2)a(2,2)b(1,2)b(2,2) and then error. What is wrong?I want to use doubles not integers.That is my code
.data
arrA: .space 32
arrB: .space 32
arrC: .space 32
msg1: .asciiz "a(1,1)="
msg2: .asciiz "a(1,2)="
msg3: .asciiz "a(2,1)="
msg4: .asciiz "a(2,2)="
msg5: .asciiz "b(1,1)="
msg6: .asciiz "b(1,2)="
msg7: .asciiz "b(2,1)="
msg8: .asciiz "b(2,2)="
.text
.globl main
main:
la $a0, arrA
la $a1, arrB
la $a2, arrC
#Prints msg1
li $v0, 4
la $a0, msg1
syscall
li $v0, 7
syscall
sdc1 $f0, 0($a0)
#Prints msg2
li $v0, 4
la $a0, msg2
syscall
li $v0, 7
syscall
sdc1 $f0, 8($a0)
#Prints msg3
li $v0, 4
la $a0, msg3
syscall
li $v0, 7
syscall
sdc1 $f0, 16($a0)
#Prints msg4
li $v0, 4
la $a0, msg4
syscall
li $v0, 7
syscall
sdc1 $f0, 24($a0)
#Prints msg5
li $v0, 4
la $a0, msg5
syscall
li $v0, 7
syscall
sdc1 $f0, 0($a1)
#Prints msg6
li $v0, 4
la $a0, msg6
syscall
li $v0, 7
syscall
sdc1 $f0, 8($a1)
#Prints msg7
li $v0, 4
la $a0, msg7
syscall
li $v0, 7
syscall
sdc1 $f0, 16($a1)
#Prints msg8
li $v0, 4
la $a0, msg8
syscall
li $v0, 7
syscall
sdc1 $f0, 24($a0)`
Upvotes: 1
Views: 44
Reputation: 58507
For each of the system calls that require integer arguments, you're modifying $a0
. And once you've done that, $a0
no longer contains the address of arrA
. So you end up storing the doubles into the memory where your strings are located.
The easiest solution would be to use another register for the address of arrA
.
And you really ought to simplify this into a loop, since you're just doing the same thing 8 times.
Upvotes: 2