Я никогда не использовал сборку MIPS раньше, и она только что была представлена в классе. Я работаю над домашним заданием, но мне сложно вызывать функцию. Вот что я разработал до сих пор:
.data
.align 2
matrix_a: .word 11, 23, 31, 46, 52, 66, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
.text
.align 2
.globl main
main:
la $a0, matrix_a #; Address of matrix_a
addi $a1, 16 #; set the second argument to the size of matrix_a, 16
jal matrix_print #; and call the function
matrix_print:
add $t3,$zero,$a0
li $t2, 0 #; And initialize $t2 = 0
add $t4, $t2, $zero #; Set $t4 = $t2, we will use $t4 for checking our loop
add $t5,$zero,$a1 #; And $t5 is our max point
Loop:
bge $t4, $t5, Exit #; If our index has reached our constraint, jump to exit
add $t2,$zero,$t4 #; Otherwise, set $t2 to equal $t4
add $t2, $t2, $t2 #; Double $t2
add $t2, $t2, $t2 #; and double it again
add $t1, $t2, $t3 #; and store $t2, the offset, + $t3, the initial address
li $v0,1 #; Get ready to system call print an int
lw $a0, 0($t1) #; Pass in $t1 to print
syscall #; Print
addi $t4,$t4,1 #; increment $t4 by 1
j Loop
Exit:
li $v0,10 #; Exit
syscall
Проблема в том, что он зацикливается вечно, поэтому я считаю, что $ a1 не проходит должным образом Этот код работает, когда я устанавливал размер прямо в функции. Может кто-то указать мне верное направление? Спасибо!