【发布时间】:2014-11-09 15:41:50
【问题描述】:
使用系统调用提示并输入两个整数“a”和“b”
根据 a>b、a=b 或 a 显示以下语句之一
您输入的 a 大于 b
您输入的等于 b
您输入的 a 小于 b
我必须得到这个提示,我非常努力地完成它。这就是我卡住的地方,非常感谢您的帮助。
.data
p1: .asciiz "Please enter the first number ? "
p2: .asciiz " Please enter the second number? "
ans1: .asciiz " \nYou entered a greater than b "
ans2: .asciiz " \nYou entered a equal to b "
ans3: .asciiz " \nYou entered a less than b "
.text
.globl main
main:
li $v0, 4 #system call code for print_str
la $a0, p1 #address of string to print
syscall #print the first prompt
li $v0, 5 #system call code for read_int
syscall #read first integer
move $t1, $v0 #store it till later
li $v0, 4 #system call code for print_str
la $a0, p2 #address of string to print
syscall #prints the second prompt
li $v0, 5 #system call code for read_int
syscall #read first integer
move $t2, $v0 #store it till later
slt $t1,$s1,$s0 # checks if $s0 > $s1
beq $t1,1,label1
我真的不知道如何使用分支语句,这真的很混乱。我想知道如何解决它。
【问题讨论】:
标签: if-statement assembly mips equals