CSC231 Homework 4 2017

From dftwiki3
Revision as of 11:19, 26 February 2017 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- <showafterdate after="20170227 11:00" before="20170601 00:00"> __TOC__ <br /> =Problem 1= <br /> Write an assembly language program that prompts the user for a amo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut (talk) 11:19, 26 February 2017 (EST)


<showafterdate after="20170227 11:00" before="20170601 00:00">

Contents


Problem 1


Write an assembly language program that prompts the user for a amount of money and outputs the number of $20-bills, $10-bills, $5-bills, and $1-bills that a teller machine will return, if this was the amount to be withdrawn.

Here is an example of how to assemble and run the solution program:

nasm -f elf teller.asm
ld -melf_i386 -o teller teller.o 231Lib.o
./teller
amount? 139

6 
1
1
4

  • The teller program prints "amount? " with a space at the end.
  • The user enter 139, and presses ENTER.
  • The program displays a blank line. This line is very important and required by the auto-grader.
  • The program then computes the number of $20-bills in $139: 6, and prints 6 followed by a new line.
  • The program then computes the number of $10 in the $19 left over, which is 1. It prints 1, followed by a new line.
  • It then computes the number of $5 in the $9 left over, or 1. It prints 1 and a new line.
  • Finally it prints the number of $1 in the $4 left over: 4. It prints 4 followed by a new line. Do not forget this last new line!

Your program should work in the exact same way. It should output no extra spaces. The prompt is "amount? ", have your program display the same word. The output is 1 blank line followed by 4 lines with only 1 number per line, and one final new line at the end.

Call your program teller.asm and submit it to the auto-grader. It will test it with 3 different amounts that result in 4 different sets of numbers. Your program will only be tested with positive numbers less than 1000.


</showafterdate>