See Below.
After reading the food cost, the program can do the calculations. It is convenient to do them all at once and then to print out the results.
## rest.asm ## ## Total restaurant bill calculator ## ## Register Use: ## ## $s0 tip+tax ## $s1 tip rate ## $s2 tax rate ## $s3 meal cost ## $a0 tax+tip dollars .globl main # Get meal cost main:$v0,4 # print a prompt (code 4 put in $v0)
$a0,prompt # address of prompt put in $a0 syscall
$v0,5 # input an integer (code 5 put in $v0) syscall # 32-bit result returned in $v0
$s3,$v0 # save it in $s3 # Calculations lw $s1,_____ # get tip rate lw $s2,_____ # get tax rate addu $s3,$s1,$s2 # total rate _____ $s4,$s0,$s3 # 100*(tax + tip) _____ $s4,$s4,100 # tax + tip _____ $s5,$s0,$s4 # total bill . . . . . .data tip: .word 15 # tip rate in percent tax: .word 8 # tax rate in percent prompt: .asciiz "Enter food cost: " head1 : .asciiz " Tax plus tip: " head2 : .asciiz " Total cost: " # end of file