MIPS 打印给定数组的值

MIPS Printing Values of a Given Array

我正在尝试在控制台上打印数组的值,这些值已在 .data 中作为 intA 给出。即,尝试在没有用户提示的情况下打印数组的值。

我的代码:

.data 

prompt: .asciiz "The values in the array are:\n"
finished: .asciiz "\nNo more values to present"
space: .asciiz " "
intA:   .word   11, 2, 3, 4, 5, 34, 0

.text 
.globl main

main:

    #Prints the prompt string
    li $v0, 4
    la $a0, prompt 
    syscall 

    # initialization of a0, a1, and t3 (i, counter)
    la $a0, intA # loading starting address (base) of array in register a0
    addi $a1, $zero, 6 # array size - 1
    addi $t3, $zero, 0 # i initialized to 0

    j loop

loop: 

    lw $t1, 0($a0) # loading integer (value of array) in the current address to register t1, I use lw because integer is a word (4 bytes)

    # printing current value of array
    li $v0, 4
    la $a2, ($t1) 
    syscall 

    # spacing between values
    li $v0, 4
    la $a2, space
    syscall 

    # checking that next address is not outside of the array
    addi $t3, $t3, 1
    slti $t2, $t3, 6
    bne $t2, 1, done   

    # accessing next integer and jumping back to print it
    addi $a0, $a0, 4
    j loop

done:

    # indicating program is done
    li $v0, 4
    la $a0, finished 
    syscall 

我得到的输出:output

知道为什么它不打印数组的值,以及打印的这些方块是什么吗?

编辑:

我改了

# printing current value of array
    li $v0, 4
    la $a2, ($t1) 
    syscall

# printing current value of array
    li $v0, 1
    lw $a2, ($t1) 
    syscall 

因为,据我所知,我打印了一个整数,所以 $v0 应该输入 1,我应该输入 lw 而不是 la(因为它是一个整数,即一个词)

但是,现在我在第 31 行收到运行时错误:lw $a2, ($t1) 告诉我

fetch address not aligned on word boundary 0x0000000b

解决方案:我需要使用 add $a0, $t1, $zero 而不是 lw $a0, ($t1) 来打印 $t1 的值,因为我正在尝试使用该值而不是访问地址。