New Array Mips Full Code [closed]

ok i did it my self, meaby somebody will use it too, so i just posting my code 😉

 .data
how: .asciiz "The size of array: "
give: .asciiz "Next value: "
writ: .asciiz "Value in array: "
n: .asciiz "\n"

.text

li $v0, 4
la $a0, how
syscall

li $v0, 5
syscall
move $t8, $v0 

jal array
jal read
jal write

end:

li $v0, 10
syscall

array:

sll $t1, $t8, 2

move $a0, $t1
li $v0, 9
syscall
move $a1, $v0

 mul $t3, $t8, 4
 move $t1, $a1
 add $t2, $a1, $t3

jr $ra

read:

li $v0, 4
la $a0, give
syscall

 li $v0, 5
 syscall
 move $t0, $v0

sw $t0, ($t1)
addi $t1, $t1, 4
bne $t1, $t2, read 

move $t1, $a1

jr $ra

write:

li $v0, 4
la $a0, writ
syscall

lw $t0, ($t1)

li $v0, 1   
move $a0, $t0
syscall

li $v0, 4
la $a0, n
syscall

addi $t1, $t1, 4
bne $t1, $t2, write

jr $ra

Leave a Comment