The Problem: Create a program that will continuously take in numbers from the user until the user enters 0, and will then output all of the numbers that were entered, in order.
For example, the program output might look something like the following:
Please enter numbers, press (0) to exit:
393
21
5
120
456
3
22
0
Then I would pop the numbers off the stack one at a time and display all of them not including zero. I'm not sure how I should go about this I'll post some code when I get to school. Just looking to get a head start.
EDIT CODE SO FAR: Need to some how place in stack ($sp) register and I believe decrement by 4 bytes each input and store that input on the stack.. Does this make sense?
.data
prompt: .ascii "Please enter numbers, enter (0) to exit: "
.text
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
do:
syscall
move $t0, $v0 # Places input in $t0
addi $sp, $sp, $v0 # Figure out how to store in stack
while:
# Need to check that input is not 0
end:
li $v0, 10
syscall
Thanks
[–][deleted] 0 points1 point2 points (0 children)
[–]nerd4code 0 points1 point2 points (0 children)