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 function in MIPS using MARS to determine whether a user input string is a...
Create a function in MIPS using MARS to determine whether a user input string is a palindrome or not. Assume that the function is not part of the same program that is calling it. This means it would not have access to your .data segment in the function, so you need to send and receive information from the function itself. The program should be as simple as possible while still using necessary procedures. Follow the instructions below carefully. Instructions: ●...
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...
user will input a set of integers until 0 is input. When each number is input,...
user will input a set of integers until 0 is input. When each number is input, output whether the number input is it even or odd. Additionally, count the even numbers input. When 0 is input, output the count of the even numbers. Write the code here including the class definition and main function:
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...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2 and 100. Reject any invalid user inputs and terminate the program if invalid inputs are entered. Print each even number from 2 to the user entered number. Sum these even numbers and print the sum. Print each odd number from 1 to the user entered number. Sum these odd numbers and print the sum. Exit the program when the output is complete. The output...
In C++, create an input validation where the user enters a signed whole number and repeats...
In C++, create an input validation where the user enters a signed whole number and repeats this process until the user enters a zero. Do not accept any value with a decimal fraction or other extraneous characters, including dollar signs. The number's sign must be preserved. Some of the steps has been done for you. Fill out the program in C++. See below for the expected console output. Program: #include <iostream> using namespace std; int main(){    signed int input;...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT