# File: mlMoney.asm # Author: ************ # Date: mm/dd/yyyy # Purpose: Practice floating point; Break down cash to bills and coins #---------------------------------------------- # WRITE MIPS
# File: mlMoney.asm # Author: ************ # Date: mm/dd/yyyy # Purpose: Practice floating point; Break down cash to bills and coins #---------------------------------------------- # WRITE MIPS CODE FOR THE FOLLOWING C++ CODE: # #include
# SAMPLE OUTPUT: # Enter amount of cash (56.68): 56.68 # # Twenty 2 # Ten 1 # Five 1 # One 1 # Quarter 2 # Dime 1 # Nickel 1 # Penny 3 .data .eqv SYS_PRINT_WORD 1 #word, byte, character .eqv SYS_PRINT_FLOAT 2 #float .eqv SYS_PRINT_DOUBLE 3 #double .eqv SYS_PRINT_TEXT 4 #text (zero terminated) .eqv SYS_INPUT_WORD 5 #input word .eqv SYS_INPUT_FLOAT 6 #input float .eqv SYS_EXIT 10 #terminate
# //declare variables cash: .word 0 remainder: .word 0 twenty: .word 2000 #20.0 ten: .word 1000 #10.0 five: .word 500 #5.0 one: .word 100 #1.0 quarter: .word 25 #0.25 dime: .word 10 #0.10 nickel: .word 5 #0.05 penny: .word 1 #0.01 hundred: .float 100.0
endl: .asciiz " " tx_prompt: .asciiz "Enter amount of cash (56.68): " tx_twenty: .asciiz " Twenty \t" tx_ten: .asciiz " Ten \t" tx_five: .asciiz " Five \t" tx_one: .asciiz " One \t" tx_quarter: .asciiz " Quarter \t" tx_dime: .asciiz " Dime \t" tx_nickel: .asciiz " Nickel \t" tx_penny: .asciiz " Penny \t" .text .globl main main: la $a0, tx_prompt # load address of prompt for syscall li $v0, SYS_PRINT_TEXT # specify Print String service syscall # print the prompt string li $v0, SYS_INPUT_FLOAT # specify Read Integer service syscall # Read the number. After this instruction, the number read is in $f0. s.s $f0, cash
# TODO: Finish computing remainder,twenty,ten,five,one,quarter,dime,nickel,penny #----------------------------------------------------------------------- #---- print results la $a0, tx_twenty li $v0, SYS_PRINT_TEXT syscall lw $a0, twenty li $v0, SYS_PRINT_WORD syscall # TODO: Finish printing ten,five,one,quarter,dime,nickel,penny
#---- terminate --- exit: li $v0, SYS_EXIT syscall #.end main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started