我想在Qtspim的控制台中打印123类型。然后打印出“答案= 123”。
为什么我的mips代码不工作??
# messages.asm
.data
str: .asciiz "the answer = "
.text
main:
li $v0,5
syscall
li $v0, 4 # system call code for print_string
la $a0, str # address of string to print
syscall # print the string
li $v0, 1 # system call code for print_int
syscall
li $v0, 10 # system call code for exit
syscall # terminate program发布于 2014-03-24 00:17:37
系统调用1 (print_integer)期望在寄存器$a0中打印该值。在您的程序中,当您执行print_integer系统调用时,$a0将不会包含123,因为您已经将$a0设置为str的地址。
发布于 2021-03-27 07:05:04
li $t0,123
li $v0, 1 # system call code for print_int
move $a0,$t0
syscall只需在代码中进行以下更改,它将输出"the answer = 123“。出现这个问题的原因是,您的字符串仍然被赋值,但您需要将其赋值为t0。移动$a0,$t0会将t0的值移到a0,这样您的代码就可以工作了
https://stackoverflow.com/questions/22593407
复制相似问题