Question

Using MIPS, create a stack that takes user input until the user inputs 0, then output...

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

Homework Answers

Answer #1

.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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a MIPS program where you ask a user for 10 digit base 28 number and...
Create a MIPS program where you ask a user for 10 digit base 28 number and output a decimal in mips programming. It should also ignore any character that is not in the base 28 system and count its value as 0. Example: Input: 100000xza! Output: 17210368 Input: xyzxyzxyzx Output:0 Input: 1000000000 Output: 17210368 Output: 10578455953408 Input: 0000000000 Output:0
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
Create .py code allowing use input float # until sentinel val of 0 is inputted. When...
Create .py code allowing use input float # until sentinel val of 0 is inputted. When zero is entered, the program with end. Should out put the following: Amount of number (#) user input, Sum of # imputted, Avg. of the numbers imputted, Lowest # entered, and Highest # entered. Python
Create a FSM that detects the input bit pattern ‘01’. The output will be ‘0’ until...
Create a FSM that detects the input bit pattern ‘01’. The output will be ‘0’ until the exact pattern ‘01’ is received. At the point of receiving ‘01’, the FSM will output 1, and then go back to output ‘0’ until the next ‘01’ is received. 1) Draw the Moore FSM diagram for the above 2) Write the FSM tables: a. State Assignment (Gray Encoding) b. State Output c. State Transition Tables 3) Simplify the Output logic (use K-Map if...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to the characters that are in the string until they are ready to stop. We will need to read in several pieces of data from the user, including a string and multiple characters. You can set a maximum size for the user string, however, the specific size of the string can change and you can’t ask them how long the string is (see the sample...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
(1) Ask the user to input a character. You will draw your right triangle with this...
(1) Ask the user to input a character. You will draw your right triangle with this character. (2) Ask the user to input the number of rows (integer). This will also signify the number of characters at the base of the triangle. (3) Use a nested loop to draw the triangle. The first line will only have one character but will now need to output enough spaces such that the character is output at the end of the row instead...
Using a loop (not the output format character %o), create a program that takes a positive...
Using a loop (not the output format character %o), create a program that takes a positive integer n, and then displays the polynomial for the octal representation of that integer. Use successive division, as demonstrated in the binary conversion example from the lesson, to do this. For example, for n = 157, the program should output the following: 157 = + (5 * 8^0) + (3 * 8^1) + (2 * 8^2) When this part is working properly, “surround” this...
Without using move or li, write MIPS assembly language using MARS simulator to print a half...
Without using move or li, write MIPS assembly language using MARS simulator to print a half pyramid depending on a value n of a user input. Such that if n = 5 were entered the following would be printed: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT