Question

In: Computer Science

Create a SPIM program that asks the user for a character string and a number. Repeatedly...

Create a SPIM program that asks the user for a character string and a number. Repeatedly display the string on the console for the number of times specified by the user.

Format your assembly program to make it easier to read by including appropriate comments and formatting using appropriate white space. When ending your program call system call code 10.

Example Output:

Please enter a string: I will not repeat myself
Please enter the integer number of times to repeat: 5
I will not repeat myself
I will not repeat myself
I will not repeat myself
I will not repeat myself

Solutions

Expert Solution

***Please upvote or thumbsup if you liked the answer***

Screenshot of the SPIM code:-

Screenshot of Output:-

SPIM code to copy:-


.data
buffer: .space 50
str: .asciiz "Please enter a string:"
prompt:   .asciiz "Please enter the integer number of times to repeat: "
  

.text

main:
  
la $a0, str # Prompt for inputting string
li $v0, 4
syscall

li $v0, 8 # load the string input

la $a0, buffer # load byte space into address
li $a1, 50 # allot the byte space for string

move $t0, $a0   
syscall
  
# initialize
li   $s0, 10
  
   # prompt for integer input
li   $v0, 4
la   $a0, prompt
syscall

   # read in the integer value
li   $v0, 5
syscall
move $s0, $v0

loop:  
   # print str
   la $a0, buffer
   move $a0, $t0   
   li $v0, 4 # print string
   syscall

   # decrement loop counter and branch if positive and non-zero
   sub   $s0, $s0, 1
   bne    $zero,$s0, loop

   li $v0, 10 # end program with system code 10
   syscall   


Related Solutions

Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663. This is my code, but I cannot figure out where to go from here. #set new number new_number = "" #split number split_num = phone.split("-") for char in split_num[1:2]:...
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm Explain step by step
In Java:Implement a program that repeatedly asks the user to input apositive integer and...
In Java:Implement a program that repeatedly asks the user to input a positive integer and outputs the factorial of that input integer. Do not use recursion, solution should use stack.
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or enter -1 to stop. When finished entering all the scores, the program should display the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. (IN PYTHON)
In java, write a program that asks the user to enter a character. Then pass the...
In java, write a program that asks the user to enter a character. Then pass the character to the following methods. isVowel() – returns true if the character is a vowel isConsonant() – returns true if the character is a consonant changeCase() – if the character is lower case then change it to upper case and if the character is in upper case then change it to lower case. (return type: char) Example output is given below: Enter a character...
In.java Write a program that repeatedly asks the user to enter their password until they enter...
In.java Write a program that repeatedly asks the user to enter their password until they enter the correct one. However, after 5 failed attempts, the program "locks out" the user. We will show that with an error message. Assume the password is HOC2141 (case sensitive). Note that there is a special case that is not shown below. To identify it, think of all possible scenarios of input for this program. ----------- Sample run 1: Enter your password: Blake Wrong Enter...
Write a simple MIPS program that asks the user to input a string and then a...
Write a simple MIPS program that asks the user to input a string and then a character. The program should then count how many times that character appears in the string and print out that value. Please use comments.
Design a program that asks the user for a number and the program computes the factorial...
Design a program that asks the user for a number and the program computes the factorial of that number and displays the result . Implement with two different modules - one that uses a for loop and one that uses a while loop Grading Rubrick Program Compiles Cleanly  syntax errors25 pts-5 per errorProgram runs without runtime errors ( validation)run-time errors 25 pts-5 per errorProgram give correct answersLogic errors30 pts-5 per errorProgram is repeatableNot repeatable5 pts-5 ptsProgram is well modularizedBarely Modularized10 pts-...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT