Create subroutine that can perform arbitrary sized addition

Assignment Help Assembly Language
Reference no: EM132326249

In this assignment, you will be creating and testing a subroutine that can perform arbitrary-sized addition. This subroutine will take arguments using the ARM Application Procedure Call Standard (APCS), and probably make use of the stack for other purposes.

Exercise - asuAdd Subroutine

In the "studentWork" project for Eclipse, fill in the asuAdd subroutine in the file asuAdd.S. The purpose of asuAdd is to do arbitrary-sized unsigned additions. One use of asuAdd can be to create a Fibonacci subroutine that can accurately calculate the Nth Fibonacci number for large values of N. So N=1000 should be no problem for example. When being called, asuAdd takes three arguments in r0, r1, and r2. r2 contains an argument called maxN0Size as described below. r0 and r1 point to arrays of 32-bit unsigned ints. Element 0 of each array stores the number of words that contain valid data in the array. For example, if element 0 contains the value 23, then the following 23 words contain valid data. The least-significant word comes first, so this is a little-endian style. Note that, now, the ARM simulator that I have built uses a little-endian version of the ARM7 processor (see https://en.wikipedia.org/wiki/Endianness). The arbitrary-sized unsigned data pointed to by r1 is added to the arbitrary-sized unsigned data pointed to by r0 and the result ends up in the arbitrary-sized unsigned data pointed to by r0. If element 0 of an array contains 0, then the value of the arbitrary-sized number as a whole is, by our definition, 0.

Sometimes a carry out in the final "partial" addition will cause a developing sum needing, up to this point, N valid words to increase in size such that it requires (N+1) words to be fully stored.

For example (written for convenience in "big-endian" style - the words are actually reversed in memory in the little-endian style):
0x80000000,80000000,80000000 +
0x80000000,80000000,80000000
0x00000001,00000001,00000001,00000000 +
This is all good and well, but what if there is no available space in memory for the extra word in the expanded result integer where that result integer is located?
I am proposing a subroutine that conforms to the following c-language function signature (using the provided typedef):
typedef unsigned int bigNumN[];
// returns -1 for error in inputs, 1 if overflow/carry-out and 0 if no overflow/carry-out
int asuAdd(bigNumN bigN0PC, const bigNumN bigN1PC, unsigned int maxN0Size);

where maxN0Size specifies the maximum number of valid words that can fit in the bigN0PC array (that is, the array size less one because word 0 in the array stores the number of valid words). In register r0 in normal cases, the subroutine returns 1/0/-1 as indicated in a comment above the function signature. maxN0Size should always be greater than or equal to the maximum of the valid words in bigN0PC or bigN1PC. If it is not, you should return -1 indicating an error condition.

Here are some examples:

Consider bigN0PC has 1 valid word and bigN1PC has 2 valid words. If maxN0Size is 1 then that is an error so in register r0 return -1 from the subroutine. If maxN0Size is 2 then there is no error, and the return value may be 0 or 1 depending. If maxN0Size is 3 in this case then the return value of the function (in register r0) will always be 0 because 3 words is always large enough to hold whatever sum is possible from an addition with operands of less than 3 words (like the 1- and 2-word operands specified in these examples).

The template project for this assignment contains testing code to test your asuAdd subroutine. It calls a library function called memcmp to compare values in memory. The linker links memcmp to our code. This is the same memcmp that can be used from C-language. Parameters to memcmp are passed in order in r0 through r2, and the return value is returned in r0.

Please add many more rows of data to the testing table so that you are doing thorough testing of your subroutine. You may also modify things to add more elements to arrays. Note, element 0 of each input array for a given test needn't contain the same value.

There might be a prize for the pair of students who come up with the fastest implementation for the bigAdd subroutine. Details to be provided if we go ahead with this. If there is a tie, the subroutine taking less space will break the tie. As mentioned in class, we expect that every student will work with a partner on this assignment.

To demonstrate that the testing code works, I have also provided a project with a C++ implementation of asuAdd. In your implementation, make use of the carry flag in the status register when doing additions. In C and C++ as defined by the language standards, there is no way to access the processor's carry flag. Therefore, I simulate a carry flag. The carry flag is simulated in a C++ class template that normally provides a C++ object wrapper for each numeric C++ primitive type. I have simply hacked the template so that we can simulate a carry flag for unsigned types, like unsigned int. In order to make things look simpler when calling asuAdd from assembly code, I have given the asuAdd function a C- language interface.

It is suggested to ask on Piazza if you have any questions.

Attachment:- Assignment.rar

Reference no: EM132326249

Questions Cloud

Writing a brief history of the two traditions : Include a brief history of the two traditions and a comparison of their approaches to the Bible, art, specific symbols, and rituals as well as core beliefs.
Determine the bonds issue price on january 1 : Flagstaff Systems issues bonds dated January 1, 2017, that pay interest semiannually on June 30 and December 31.
Discuss what earnings quality is : Sarbanes-Oxley Act (SOX) was introduced in 2002 by the United States Congress to fight corporate financial statement fraud.
How will you reflect on your teaching of the unit and lesson : How will the unit be evaluated? How will you decide if the students successfully completed the unit? How will you reflect on your teaching of the unit.
Create subroutine that can perform arbitrary sized addition : ENSC 254 - Introduction to Computer Organization - Simon Fraser University - creating and testing a subroutine that can perform arbitrary-sized addition
Explain the concept of the critical path and float-slack : Explain the concept of the critical path and float/slack time. Your answer should include why the critical path is so important to project management.
What was the fixed manufacturing overhead budget variance : Teall Corporation has a standard cost system in which it applies manufacturing overhead to products on the basis of standard machine-hours (MHs).
Prepare a reconciliation of plan assets for 2020 : Prepare a reconciliation of plan assets for 2020. Compute the plan's funded balance on the beginning and ending dates.
Evidence-based management in healthcare : Please review Chapter 7 of Evidence-Based Management in Healthcare before responding to the below prompt.

Reviews

Write a Review

Assembly Language Questions & Answers

  Write an assembly program

Run your program using decimal 5 as input for x. Provide a screenshot showing the result of program execution in decimal.

  Stack structure for unsigned integers

Write a program to push 10 items into your stack, and pop them out - Use MARIE's ISA program a stack structure for unsigned integers.

  Multiply by using shift and add instructionsyou have

multiply by using shift and add instructionsyou have studied shift and rotate instructions. when a number is shifted

  Describe advantage of program-counter-relative addressing

Describe one advantage and one disadvantage of program-counter-relative addressing. The Core i7 has a condition code bit that keeps track of the carry out of bit 3 after an arithmetic operation. What good is it?

  Write two-pass assembler for subset of mips instruction set

Write a two-pass assembler for a subset of the MIPS instruction set. It should be able to read an assembly file from the command line and write the object code to standard output.

  Analog measurements

Prepare an assembly program for the correctly measures the wind direction

  Study code and find how two dimensional array is accessed

Create a procedure called calc_col_sum which uses the same registers as the original procedure EBX ECX EDX ESI - The procedure return value should be in EAX.

  Writing program using arm instructions - sort the numbers

TSN1101 – Computer Architecture and Organization - Write a program in ARM Assembly Language Program to check 2 Sets of temperature readings

  Program [hcs12 assembly language] to compute the average

Write a program [HCS12 assembly language] to compute the average of an array of N 8-bit numbers and store the result at $1000

  Allot op-codes and add microcode to microprogram

Allot op-codes and add microcode to microprogram of Mic-1 to implement following instructions which are then included with IJVM instruction set.

  Convert file of strings to a base64 encoding

Take a file of strings (Which may be binary data) and convert those string to a Base64 encoding.

  Write a program in assembly code for the simulator

Write a program in assembly code for the simulator that will count from 107 to 14 backwards by 3 and display the counter in the output on each iteration of the loop. (Must be in R1, R2, load and add form)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd