1.读取两个整数,输出它们的和与差
2. 读入一个string变量并且将其输出
3. 读入两个整数,将其中较大的一方输出。
4.
5.
6.
main:
## Get first number from user, put into $t0.
li $v0, 5 # load syscall read_int into $v0
syscall # make the syscall
move $t0, $v0 # move the number read into $t0
## Get second number from user, put into $t1.
li $v0, 5 # load syscall read_int into $v0
syscall # make the syscall
move $t1, $v0 # move the number read into $t0
add $t2, $t0, $t1
sub $t3, $t0, $t1
## Print out $t2 & $t3
move $a0, $t2 # move the number to print into $a0
li $v0, 1 # load syscall print_int into $v0
syscall # make the syscall
move $a0, $t3 # move the number to print into $a0
li $v0, 1 # load syscall print_int into $v0
syscall # make the syscall
jr $ra
2. 读入一个string变量并且将其输出
.text
main:
la $a0, hello_msg # load the address of hello_msg into $a0
li $v0, 4 # load syscall print_string into $v0
syscall # make the syscall
jr $ra
.data
hello_msg: .asciiz"Hello, World!\n"
3. 读入两个整数,将其中较大的一方输出。
main:
li $v0,5
syscall
move $t0, $v0
li $v0,5
syscall
move $t1, $v0
bgt $t0, $t1, t0_bigger
move $t2,$t1
b endif
t0_bigger:
move $t2, $t0
endif:
move $a0,$t2
li $v0,1
syscall
jr $ra;
4.
5.
6.