比较两个整数并尝试在0x00400058处执行非指令

时间:2019-10-18 08:29:26

标签: assembly integer compare mips

我有一个作业问题,比较两个整数并根据结果进行按摩。

我一直在尝试在0x00400058消息上执行非指令。

.data
msg1:.asciiz "Give me the first number:"
msg2:.asciiz "Give me the second number:"
msg3:.asciiz "The grater number is:"
msg4:.asciiz "The smaller number is:"
msg5:.asciiz "The two numbers are equal"
msg6:.asciiz "The two numbers are not equal"


.text
.globl main
main:
li $v0,4
la $a0,msg1 
syscall


li $v0,5
syscall
move $t2,$v0


li $v0,4
la $a0,msg2
syscall


li $v0,5
syscall
move $t3,$v0


beq $t2,$t3,numbersEqual
bge $t2,$t3,number1isBigger
bge $t3,$t2,number2isBigger

numbersEqual:
li $v0,4
la $a0,msg5
syscall

move $v0,$t2
li $v0,1
syscall

li $v0,4
la $a0,msg4
syscall

move $v0,$t3
li $v0,1
syscall

nop

number1isBigger:
li $v0,4
la $a0,msg6
syscall

li $v0,4
la $a0,msg3
syscall
move $v0,$t2


li $v0,1
syscall


li $v0,4
la $a0,msg4
syscall
move $v0,$t3


li $v0,1
syscall

nop


number2isBigger:

li $v0,4
la $a0,msg6
syscall

li $v0,4
la $a0,msg3
syscall
move $v0,$t3


li $v0,1
syscall


li $v0,4
la $a0,msg4
syscall
move $v0,$t2


li $v0,1
syscall
nop

exit:
    li      $v0, 10              # syscall 10 terminates program 
    syscall

0 个答案:

没有答案