Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer using x86 processor assembly language thanky you Part 1 (10 pts total) Go to the section labeled Part 1 in lab4.asm and add

please answer using x86 processor assembly language thanky you

image text in transcribed

image text in transcribed

Part 1 (10 pts total) Go to the section labeled "Part 1" in lab4.asm and add code to the existing program to calculate the number of coins in a cash payment Example: a customer buys an item for $4.35 and gives a $5 bill for payment. The change amount would be 65 cents, and the program will print out that the change is: 2 quarters, 1 dimes, 1 nickels, o pennies (It's okay to end all the coin names with 's' even if there's 1 coin - don't tell your English instructors) Here are the steps to complete the program (6/10 pts): a. Create a constant called MAX and set it to 99 (this is the max change amount of 99 cents) b. The change amount is simulated by a random number between 0 and MAX. Call the randomRange procedure to get a random number between 0 and MAX (make sure you use MAX and not 99 in the code). Run the sample code in lab4.asm to see how to call randomRange, then modify the code so that randomRange returns a random number between 0 and MAX. This random number will be the change amount. C. From the change amount, calculate the number of quarters, dimes, nickels, and pennies. Here's the pseudocode for converting the change amount to coins: Pseudocode Example num quarters = change amount / 25 65 / 25 = 2 (quarters), remainder: 15 update change amount to remainder num dimes = change amount / 10 15 / 10 = 1 (dime), remainder: 5 update change amount to remainder num nickels = change amount / 5 5/5 = 1 (nickel), remainder: 0 (pennies) num pennies = remainder d. Print the result in this format: N quarters, N dimes, N nickels, N pennies where N is the calculated number of each coin. Make sure the output string ends with a ' ' (in assembly) so that it's on a line by itself. Sample output: Change is 36 cents 1 quarters, 1 dimes, 0 nickels, 1 pennies DON'T MISS these additional requirements: 1. (2/10 pts) Except for text string variables, which are arrays, the program should use NO memory variables to store numbers. What should you use instead, which are faster to access than variables? 2. (2/10 pts) Given the range of data in the program, use the smallest* data size (not DWORD) in all your calculation. But make sure you use DWORD data when printing numbers because the Irvine32 10 library works with 32 bit data. This is an exercise with 3 learning objectives: - to practice using different size data - to be aware of when data can change size in an arithmetic operation - to be aware of when you should change the size of the data TITLE Lab 4: Calculate the number of coins, and predict flag values ; Don't forget this beginning documentation with your name ; Name: INCLUDE Irvine32.inc ; Part 1 (10pts) .data .code main PROC call randomize mov eax, 9 call randomRange inclusive call writeDec ; create a seed for the random number generator ; set upper limit for random number to 9 ; random number is returned in eax, and is 0-9 ; print to check random number exit main ENDP END main COMMENT ! Part 2 (5pts) Assume ZF, SF, CF, OF are all o at the start, and the 3 instructions below run one after another. a. fill in the value of all 4 flags after each instruction runs b. show your work to explain why CF and OF flags have those values Your explanation should not refer to signed or unsigned data values, such as "the result will be out of range" or "204 is larger than a byte" or "adding 2 negatives can't result in a positive" Instead, show your work in the same way as in the exercise 4 solution. mov al, 70h add al, 30h OF = ; a. ZF = SF = 1 CF = ; b. explanation for CF: ; explanation for OF: sub al, 070h OF = ; a. ZF = SF = CF = ; b. explanation for CF: : explanation for OF

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago