ARM Assembly Language: Making Change
Please
use GNU Toolchains to compile the program
Topics: Replacing division by reciprocal
multiplication, replacing multiplication by a sequence of addition, subtraction
and shift instructions, referencing structure members from assembly.
Background:
This lab uses the two structures defined below to specify the number of bills
of each of four different denominations and the number coins of each of four
types:
Assignment:
Create two assembly language functions that fill-in the values of the structure
members by finding the smallest number of bills that add up to dollars and the
smallest number of coins that add up to cents. For example, the number of
twenty-dollar bills may be computed as the integer quotient of ???????
÷ 20; the remainder is then used to find the number of ten-dollar bills, and so
on. You will soon discover most of the code in the two functions is identical;
use this fact to reduce the amount of code you write.
void Bills(uint32_t dollars, BILLS
*paper) ;
void Coins(uint32_t cents, COINS
*coins) ;
Important:
The objectives of this assignment are to (1) implement multiplication by a
constant without a multiply instruction, and (2) implement division by a
constant without a divide instruction.
For this lab you are given an amount, and are
tasked to find the smallest amount of bills/cents that adds up to that amount.
The purpose of this lab is NOT to use the MUL
or UDIV instructions, since they take many clock cycles, and instead perform
the arithmetic with techniques covered in Chapter 8. This (Links to an external site.) webpage will do the
hard work for you, as it computes the magic constant and gives you the assembly
instructions for performing division by a constant. When using this website,
please set the "Data Type" at the top right to UNSIGNED. You will
notice that several instructions are in bold -- these instructions you will
definitely use in your code. Please note however, do no simply copy and paste,
since the register operands may not be the same.
Get Free Quote!
424 Experts Online