Using MIPS, create a stack that takes user input until the user inputs 0, then output the characters that were entered onto the stack. Make sure to use $sp. Example:
Please enter a number. Press 0 to quit:
4
5
2
5
7
0
Your numbers were:
4
5
2
5
7
.data
input_prompt: .asciiz "Plese enter a number. Press 0 to
quit:\n"
new_line: .asciiz "\n"
output_line: .asciiz "Your numbers were:\n"
.text
.globl main
main:
li $v0, 4
la $a0, input_prompt
syscall
addi $sp, -4
move $s1, $sp
li $s2, 0
input:
li $v0, 5
syscall
move $t0, $v0
beq $t0, 0, output1
sw $t0, 0($sp)
addi $sp, $sp, -4
addi $s2, $s2, 1
j input
output1:
li $v0, 4
la $a0, output_line
syscall
output:
beq $s2, 0, end
lw $t0, 0($s1)
li $v0, 1
move $a0, $t0
syscall
li $v0, 4
la $a0, new_line
syscall
addi $s2, $s2, -1
addi $s1, $s1, -4
j output
end:
li $v0, 10
syscall
#Code Snippet
#Output
Get Answers For Free
Most questions answered within 1 hours.