-1

我只是想把这个'a'打印到屏幕上,但是通过首先推送到堆栈以便我可以检查我是否确实完成了推送到堆栈,似乎我不能,因为它每次都会打印一个奇怪的字符。怎么了?

.data
char: .word 'a'
.text
.globl main
main:
la $t0, char
sub $sp, $sp, 4       #allocate byte for stack
sb $t0, 0($sp)          #push to stack
la $t1, 0($sp)          #I wasnt able to print the top of the stack directly so I tried this


li $v0, 11
la $a0, 0($t1)          #It isnt working anyway.. Prints É
syscall

add $sp, $sp, 4
jr $ra
4

1 回答 1

-1

在尝试了我为使其发挥作用所做的一切方法之后,我正在提出我的解决方案。仍然不知道为什么这个有效,但是,不管它做什么。

.data
char: .word 'a'
.text
.globl main
main:
la $t0, char
addi $sp, $sp, -4       #allocate byte for stack
sw $t0, 0($sp)          #push to stack
lw $t1, 0($sp)          #load from stack



li $v0, 4
la $a0, 0($t1)          #It now puts 'a'
syscall

add $sp, $sp, 4
jr $ra
于 2013-11-06T22:14:11.503 回答