Cannot print out integer in MIPS Assembly program -
Cannot print out integer in MIPS Assembly program -
i using qtspim mips simulator , having hard time figuring out how print out integer user input. far, code is:
.data prompt: .asciiz "please come in integer: " .text main: li $v0, 4 la $a0, prompt syscall li $v0, 5 move $s0, $v0 syscall li $v0, 5 move $s1, $v0 syscall li $v0, 5 move $s2, $v0 syscall jal order3 li $v0, 1 move $a0, $s0 syscall li $v0, 10 syscall swap: move $t0, $a0 move $a0, $a1 move $a1, $t0 jr $ra swap1: move $t0, $a1 move $a1, $a2 move $a2, $t0 jr $ra order3: bgt $a0, $a1, swap bgt $a1, $a2, swap1 bgt $a0, $a1, swap jr $ra
every time seek print out first integer, prints out 5, shouldn't. not know why happening. if point out flaw in code great.
thanks.
you're trying utilize result of syscall
before syscall
has been performed:
li $v0, 5 move $s0, $v0 syscall
that should be:
li $v0, 5 syscall move $s0, $v0
same other 2 read_int
syscalls.
then there's fact order3
routine checking/altering $a0..$a2
, while numbers in $s0..$s2
.
assembly mips qtspim
Comments
Post a Comment