'Getting Multiple values in MIPS
I need to get some values from the user in a MIPS program. User needs to enter how many numbers are there and then on next line he needs to enter those numbers. For eg,
Enter N: 5
Enter N integers: 100 -800 1000 450 -500
Here's my attempt
.data
promptTrans: .asciiz "Enter N: "
numTrans: .asciiz "Enter N Integers(Use Space): "
.text
main:
la, $a0, promptTrans # Get the address of the string ready for the syscall
li $v0, 4 # syscall code for print string
syscall
li $v0, 5 # Syscall code for read integer
syscall
move $t0, $v0 # copy the inputted character to $t0
la, $a0, numTrans # Get the address of the string ready for the syscall
li $v0, 4 # syscall code for print string
syscall
li $v0, 5 # Syscall code for read integer
syscall
move $t0, $v0 # copy the inputted character to $t0
But I am not sure this is the right approch. Because later in the code I need to iterate over those number and distinguish between positive and negative numbers. Any help is appreciated, thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|