MIPS Assembly program not outputting the correct integers -
Then, in my MIPS program, users enter 3 integers and order them at least the greatest and print them We do. My code is as follows:
.data prompt: .asciiz "Please enter an integer:" .text main: li $ v0, $ 4 a $, prompt solicitor $ $ v0, 5 syscall moves $ s0, $ v0 li $ v0, 5 syscall move $ s1, $ v0 li $ v0, 5 syscall move $ s2, $ v0 jal command 3 li $ v0, move $ a0, $ s0 syscall li $ v0 , 1 step $ A1, $ s1 syscall li $ v0, 1 step $ a2, $ s2 syscall li $ v0, 10 syscall swap: $ t0 move, $ s0 moves $ s0, $ s1 moves $ s1, $ t0 jr $ ra swap1: move $ t, $ s1 move $ s1, $ s2 shake $ s2, $ t0 jr $ ra order 3: bgt $ s0, $ s1, swap bgT $ s1, $ s2, swap 1 bgt $ s0, $ S1, swap jr $ ra < / Code> The problem is that this program is simply entering the first number that I have entered. For example, if I enter 60,50,70 as my 3 inputs, then it is outputting three times three times. I do not know why this is doing this. I'm guessing that there is something to do with my order 3 function or the way I am outputting these values.
You should always use the register $ A0 to print an integer through syscall.
li $ v0, move $ a0, $ s0 syscall li $ v0, move $ a0, $ s1 syscall li $ v0, 1 to $ a0, $ s2 syscall And it seems that the Brunch (BGT) does not save the pointer to return. Therefore it is better to use these types of jumps.
order3: blt $ s0, $ s1, next move $ t0, $ s0 moves $ s0, $ s1 moves $ s1, $ t0 forward: blt $ s1, $ s2, next 2 moves $ T, $ s1 moves $ s1, $ s2 moves $ s2, $ t0 ahead 2: blt $ s0, $ s1, fun move $ t0, $ s0 moves $ s0, $ s1 move $ s1, $ t0 fin: junior ra
Comments
Post a Comment