How to fill 2-dimensional array with floating points?
Using Assemply I need a simple code that fill a 2-dimensional array
Update: That what I got so far. But still I have a problem in printing the array!
.data
arrayf: .word 600
msg1: .asciiz "Enter N: "
msg2: .asciiz " rows by "
msg3: .asciiz " values. Enter them: "
doneFill: .asciiz "Done with filling array\n"
.text
main:
li $v0, 4
la $a0, msg1
syscall
li $v0, 5
syscall
move $a1, $v0 # $a1 = N
li $v0, 1
move $a0, $a1
syscall
li $v0, 4
la $a0, msg2
syscall
move $a0, $a1
addu $a0, $a0, 1
li $v0, 1
syscall
li $v0, 4
la $a0, msg3
syscall
la $t1, arrayf
move $t0, $a1
add $t0, $t0, 1
mul $t0, $t0, $a1 # $t0 = N * (N+1)
fill:
li $v0, 6
syscall
swc1 $f0, 0($t1)
addi $t1,开发者_Go百科 $t1, 4
subi $t0, $t0, 1
bnez $t0, fill
li $v0, 4
la $a0, doneFill
syscall
la $t1, arrayf
print
lwc1 $f12, 0($t1)
c.eq.s $f12, $f30
bc1t exit
li $v0, 2
syscall
add $t1, $t1, 4
j print
Use 2 loops, one for columns and one for rows. Given array[a][b]
the offset of array[x][y]
is x + y*a
I found the problem.
It was in the print procedure. The condition to branch to exit was wrong.
Thanks @blackbear & @Carl for spending your time trying to help me :)
精彩评论