COEN20 – Programming Lab #4a (Solution)

$ 20.99
Category:

Description

Solving Quadratics
Topics: Instructions for integer arithmetic, calling a C function from assembly.
Prerequisite Reading: Chapters 1-5

Create a single ARM Cortex-M4 assembly source code file containing four functions. (Note that functions ๐‘…๐‘œ๐‘œ๐‘ก1 and ๐‘…๐‘œ๐‘œ๐‘ก2 should both contain calls to functions ๐ท๐‘–๐‘ ๐‘๐‘Ÿ๐‘–๐‘š๐‘–๐‘›๐‘Ž๐‘›๐‘ก and ๐‘†๐‘ž๐‘ข๐‘Ž๐‘Ÿ๐‘’๐‘…๐‘œ๐‘œ๐‘ก.) Functions ๐ท๐‘–๐‘ ๐‘๐‘Ÿ๐‘–๐‘š๐‘–๐‘›๐‘Ž๐‘›๐‘ก, ๐‘…๐‘œ๐‘œ๐‘ก1, ๐‘…๐‘œ๐‘œ๐‘ก2 and ๐‘„๐‘ข๐‘Ž๐‘‘๐‘Ÿ๐‘Ž๐‘ก๐‘–๐‘ are called by a main program (download from here) that will test your functions for three test cases. All of the parameters and return values are of type int32_t:
1. ๐ท๐‘–๐‘ ๐‘๐‘Ÿ๐‘–๐‘š๐‘–๐‘›๐‘Ž๐‘›๐‘ก(๐‘Ž, ๐‘, ๐‘) = ๐‘2 โˆ’ 4๐‘Ž๐‘
2. ๐‘…๐‘œ๐‘œ๐‘ก1(๐‘Ž, ๐‘, ๐‘) =
โˆ’๐‘+๐‘†๐‘ž๐‘ข๐‘Ž๐‘Ÿ๐‘’๐‘…๐‘œ๐‘œ๐‘ก(๐ท๐‘–๐‘ ๐‘๐‘Ÿ๐‘–๐‘š๐‘–๐‘›๐‘Ž๐‘›๐‘ก(๐‘Ž,๐‘,๐‘))

2๐‘Ž
3. ๐‘…๐‘œ๐‘œ๐‘ก2(๐‘Ž, ๐‘, ๐‘) =
โˆ’๐‘โˆ’๐‘†๐‘ž๐‘ข๐‘Ž๐‘Ÿ๐‘’๐‘…๐‘œ๐‘œ๐‘ก(๐ท๐‘–๐‘ ๐‘๐‘Ÿ๐‘–๐‘š๐‘–๐‘›๐‘Ž๐‘›๐‘ก(๐‘Ž,๐‘,๐‘))

2๐‘Ž
4. ๐‘„๐‘ข๐‘Ž๐‘‘๐‘Ÿ๐‘Ž๐‘ก๐‘–๐‘(๐‘ฅ, ๐‘Ž, ๐‘, ๐‘) = ๐‘Ž๐‘ฅ2 + ๐‘๐‘ฅ + ๐‘

Note: Function SquareRoot is a function written in C implemented in the same source code file as the main program. It requires a single unsigned integer parameter and returns an unsigned integer result. It should be called from your assembly language functions Root1 and Root2.

If your code is correct, the three test cases should look similar to the image above. Incorrect values will be displayed as white text on a red background.

Reviews

There are no reviews yet.

Be the first to review “COEN20 – Programming Lab #4a (Solution)”

Your email address will not be published. Required fields are marked *