Question

program has to be written in X86 processor assy language. Write a program that find the...

program has to be written in X86 processor assy language.

Write a program that find the minimum number of coins that can represent an amount of money under $1.

  1. The amount of money is a random number between 0 and 99 (cents).
  • The randomRange procedure is used to get a random number.
  • Review the sample code in lab4.asm and run it to see how randomRange works. Each time

randomRange is called, it creates a random number between 0 and the limit.

  • Once you figure out how randomRange works, remove the sample code but keep the randomize procedure call.
  • (main Proc
    call randomize
    mov eax, 10
    call randomRange
    call writeDec
    call crlf
    exit
    main ENDP
    END main)
  1. Create a CONSTANT called MAX and set it to 100.

  1. Call randomRange to generate a random number between 0 and MAX. Then print the random number with the text string in the format:   Amount = <random number> cents

Make sure to have a newline at the end of the printed string.

  1. Calculate the minimum number of quarters, dimes, nickels, pennies that it takes to add up to the random number (the amount of money).

To do this:

  • divide the random number by 25, the quotient is the number of quarters
  • divide the remainder by 10, the quotient is the number dimes
  • divide the remainder by 5, the quotient is the number of quarters
  • the remainder is the number of pennies

  1. Print the number of each type of coins with a text explanation such as:

      3 quarters, 2 dimes, 0 nickels, 1 pennies

It's okay to print the ending 's' even if the number is 1.

Make sure to have a newline at the end of the printed string.

Sample program output

Amount = 78 cents

3 quarters, 0 dimes, 0 nickels, 3 pennies

Additional requirements (make sure to read all 3 requirements)
1. Except for text string variables, the program should not use any memory variable to store numeric data. Instead, use registers. (Why?)

2. Given the range of data in the program, use the *smallest* data size (not DWORD) in all your calculations. But you will still need to use DWORD for printing data.

3. Determine whether the data is signed or unsigned, and use the appropriate instructions.

Homework Answers

Answer #1

function[coins] = change12(money)

%initial amounts of each coin

quarter = 0;

dime = 0;

nickle = 0;

penny = 0;

% money = [quarter dime nickle penny]; money =[0 0 0 0]

while money>0 % while money>=0 makes an infinte loop

if money >= 25

money = money - 25;

quarter = quarter + 1;

elseif money >= 10

money = money - 10;

dime = dime + 1;

elseif money >= 5

money = money - 5;

nickle = nickle + 1;

elseif money >= 1

money = money - 1;

penny = penny +1;

end

end

coins = [quarter dime nickle penny];

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a Change application that prompts the user for an amount less than $1.00 and then...
Create a Change application that prompts the user for an amount less than $1.00 and then displays the minimum number of coins necessary to make the change. The change can be made up of quarters, dimes, nickels, and pennies. The application output should look similar to: Enter the change in cents: 212 The minimum number of coins is: Quarters: 8 Dimes: 1 Nickels 0 Pennies: 2 Must be coded in Java please
Write a program that input some number of cents (see less than 100), and output the...
Write a program that input some number of cents (see less than 100), and output the number of quarters, dimes, nickels and pennies needed to add up to that amount (thinking how a cashier needs to return you back some small changes).
USE PYTHON Please!!! 4.15 LAB: Exact change Write a program with total change amount as an...
USE PYTHON Please!!! 4.15 LAB: Exact change Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the Irvine library for the print function #include <iostream> // The string that needs to be printed char word[] = "Golf\0"; // Pointer to a specific character in the string char * character = word; //NOTE: This main() function is not portable outside of Visual Studio void main() { // Set up a LOOP - See the while loop's conditional expression below int ecx =...
would someone kindly convert the following C code to java? thanks so much # include <stdio.h>...
would someone kindly convert the following C code to java? thanks so much # include <stdio.h> int main(void) { int changeOwed; int check; char invisibleChar; int count = 0; int numQ=0, numD=0, numN=0, numP=0; do{ printf("How much change is owed (in cents)?\n"); check = scanf("%d", &changeOwed); // returns 1 if the input is a number and returns 0 otherwise //Get's rid of any extra invisible characters if the input is a char/String do{ scanf("%c",&invisibleChar); }while(invisibleChar != '\n'); }while(check == 0...
In assembly masm use the code below! Write a program that reverse a string using indirect...
In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ;...
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
Program Instructions Write a program called censor.py. This program will have the following functionality and requirements:...
Program Instructions Write a program called censor.py. This program will have the following functionality and requirements: Has a main function: That asks the user to input a sentence Then asks the user to enter a list of words they want to replace (separated by spaces) Calls a function called replaceMultiWords passing those two parameters, which returns a filtered string Prints out the filtered (censored) string to the console Has a replaceMultiWords function that: Takes a string "sentence" and a string...
Write a Java program named BinaryConversion that will convert base 2 numbers to base 10 numbers....
Write a Java program named BinaryConversion that will convert base 2 numbers to base 10 numbers. The data for this program will be entered from the keyboard using JOptionPane one 16-bit binary number at a time. Note that each base 2 number is actually read in as a String. The program should continue until a 16-bit base 2 number consisting of all 0’s is entered. Once the 16-bit number has been entered your program should make sure that the input...