我尝试做简单的if语句。 代码是:
int x = 10;
if (x > 5)
{
output("x is greater than 5\n");
}
output("end\n");
汇编代码是:
.data
x: .word
str1: .asciiz "x is greater than 5\n"
str2: .asciiz "end\n"
.text
li $t0, 10
sw $t0, x
lw $t0, x
li $t1, 5
bgt $t0, $t1, LBL1
ble $t0, $t1, LBL2
LBL1:
li $v0, 4
la $a0, str1
syscall
LBL2:
li $v0, 4
la $a0, str2
syscall
结果始终只显示第二个字符串。无论我如何改变数据,它都无法改变数据。去第一个标签。有什么问题?
@Michael-谢谢,这是正确的解决方案。这完全是关于
x: .word 0