MIPS汇编的一些帮助-跳转和链接

MIPS汇编的一些帮助-跳转和链接,mips,Mips,我以前从未使用过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 #; Add

我以前从未使用过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美元没有正确地通过。这段代码在我直接在函数中设置大小时起作用。谁能给我指出正确的方向吗?谢谢

在添加$a1,16的行中,在添加16之前,$a1的值是多少?

太棒了,我知道了。就我而言,语法很差-我想将$a1设置为16,而不是将16添加到$a1。现在工作,谢谢!(对于阅读本文的读者,我想要的是:addi$a1、$0、16