Question

In: Computer Science

Write a MIPS assembly program that prompts the user for some number of cents (integer) and...

Write a MIPS assembly program that prompts the user for some number of cents (integer) and read the user input. Then translate that number of into a number of quarters, dimes, nickels and pennies (all integers) equal to that amount and outputs the result. The output should adequately tell the user what is being output (not just the numeric results).

Solutions

Expert Solution

The required MIPS program is provided below. Please comment if you have any doubt.

MIPS Program:

.text
main:   
# Prompt
li $v0, 4
la $a0, inp
syscall

# Read integer
li $v0, 5
syscall
move $t2, $v0

li $s1, 25
div $t2,$s1
mfhi $t0 # Remainder
mflo $t1 # Quotient

# Print string
li $v0, 4
la $a0, output
syscall

# Output result quarters
li $v0, 1
move $a0, $t1
syscall


li $s1, 10
div $t0,$s1
mfhi $t0 # Remainder
mflo $t1 # Quotient

# Output string
li $v0, 4
la $a0, output1
syscall

# Output result dimes
li $v0, 1
move $a0, $t1
syscall

li $s1, 5
div $t0,$s1
mfhi $t0 # Remainder
mflo $t1 # Quotient

# Output string
li $v0, 4
la $a0, output2
syscall

# Output result nickels
li $v0, 1
move $a0, $t1
syscall

# Output string
li $v0, 4
la $a0, output3
syscall

# Output result pennies
li $v0, 1
move $a0, $t0
syscall

# Exit the program
li $v0, 10
syscall

.data
inp: .asciiz "Enter number of cent: "
output: .asciiz "\nNumber of quarters: "
output1: .asciiz "\nNumber of dimes: "
output2: .asciiz "\nNumber of nickels: "
output3: .asciiz "\nNumber of pennies: "

Output:


Related Solutions

Write a MIPS assembly program that prompts the user for some number of cents (integer) and...
Write a MIPS assembly program that prompts the user for some number of cents (integer) and read the user input. Then translate that number of into a number of quarters, dimes, nickels and pennies (all integers) equal to that amount and outputs the result. The output should adequately tell the user what is being output (not just the numeric results). (Make sure you use comments next to each line to describe what actions you are taking in your code. )...
Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
Write a mips assembly code program that ask the user to enter an integer value, and...
Write a mips assembly code program that ask the user to enter an integer value, and then print the result of doubling that number.
Write a mips assembly language program that asks the user to enter an unsigned number and...
Write a mips assembly language program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a...
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a file. Each pair will then be multiplied together with the results being accumulated (added together) forming a sum-of-products operation. Submit your report and code here.
Write an assembly language program that repeatedly prompts the user to enter signed decimal integer numbers....
Write an assembly language program that repeatedly prompts the user to enter signed decimal integer numbers. The program should be run from the command prompt, output a text prompt to the screen, and then wait for the user to type in a number followed by the Enter key. (The legitimate range of user input values is any signed integer that can be represented in 32 bits.) After each number is entered, the program should determine and display the following information...
Write a program that prompts the user to enter a positive integer and then computes the...
Write a program that prompts the user to enter a positive integer and then computes the equivalent binary number and outputs it. The program should consist of 3 files. dec2bin.c that has function dec2bin() implementation to return char array corresponding to binary number. dec2bin.h header file that has function prototype for dec2bin() function dec2binconv.c file with main function that calls dec2bin and print results. This is what i have so far. Im doing this in unix. All the files compiled...
Problem 4 : Write a program that prompts the user to enter in an integer and...
Problem 4 : Write a program that prompts the user to enter in an integer and then prints as shown in the example below Enter an integer 5 // User enters 5 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 Bye
Write a program which: Prompts the user for a positive integer >= 0 Validates the user...
Write a program which: Prompts the user for a positive integer >= 0 Validates the user input to ensure it is a positive integer >= 0 Allocate (dynamically) an array big enough for the data. Load the array with random numbers ranging in value from1 to 100 Display the elements of the array (unsorted) Display the elements of the array (sorted) Display the average Display the median Display the mode, if none, display appropriate message RESTRICTIONS No global variables No...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT