Objective: Given the below code in Python that tests the function div10, teams are to implement all parts of function and the test program in ARM assembler.
Specifics: There are a number of requirements for this project.
This project should be instantiated via the lab08 directory containing a bare and share git initialization in your team repository area on thor.
The project should implement the div10 function in a separate file and the main function in a separate file and both are to be C-like implementations — for example, main should return a 0 back to the operating system.
Before you do any coding for the div10 and main functions, you should create a Makefile patterned after demo presented in class. The top-level target should be lab08 (the name of the executable) which depends on main.o and div10.o. And so on. There should also be a clean target.
The algorithm is demonstrated to you in Python rather than C since returning two values from a function in C is a bit tricky.
Your implementations should adhere to the register usage conventions presented in Chapter 5, Section 5.4.6 page 117 (also see Figure 5.1 p. 112). That means that div10 should return its result in R0 and R1 while the argument passed to it should be in R0. Given that there is no recursion, you need not create a frame — meaning you might be able to not even have to push the link register. NOTE that if your div10 uses R4-R11 and R13, those registers must be preserved before being used and restored before returning to the caller. Feel free to use push/pop or the stmfd/ldmfd to mange saving/restoring the registers.
Both functions should be well documented.
Your working directory (and remote repository) MUST contain a README.txt file that indicates names of team members and the percentage of contribution to the project. Of course the percentages must add to 100%. If it turns out that this effort is not roughly the same for all team members, that MUST be documented up front and should match our review of your work history as revealed by git log and git blame.
Details: There are a number of overarching details that MUST be a part of your implementations.
First, every function must have the following directives (where funcName is the name/entry point for the function):
/* data section entries if any */
.type funcName, %function
Second, every function must be documented with a “flower box” style commentary prologue.
Submission: Your work will exist in your “remote” team repository by the due date/time. In addition, there must be an entry in this drop box, also by the due date/time, indicating when your team finished the project.
def divU10( aNum ): #Unsigned division
# by: H. Paul Haiduk derived from insights in
# Hacker’s Delight, 2nd ed.
q = (aNum >> 1) + (aNum >> 2)
q = q + (q >> 4)
q = q + (q >> 8)
q = q + (q >> 16)
q = q >> 3
r = aNum – (((q << 2) + q) << 1)
if (r > 9):
q += 1
r -= 10
# end div10
number = (1 << 31) – 1 # MAXINT for 32-bit ints
while number > 0:
print(“The number is %d” % number)
(quotient, remainder) = div10(number)
print(“The number div10 yields quotient %d and remainder %d” %
(quotient, remainder) )
number = quotient