$25
Programming Lab #4a
Solving Quadratics
Topics: Instructions for integer arithmetic, calling a C function from assembly.
Prerequisite Reading: Chapters 1-5
Revised: August 27, 2019
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:
𝐷𝑖𝑠𝑐𝑟𝑖𝑚𝑖𝑛𝑎𝑛𝑡(𝑎, 𝑏, 𝑐) = 𝑏2 − 4𝑎𝑐
𝑅𝑜𝑜𝑡1(𝑎, 𝑏, 𝑐) =
−𝑏+𝑆𝑞𝑢𝑎𝑟𝑒𝑅𝑜𝑜𝑡(𝐷𝑖𝑠𝑐𝑟𝑖𝑚𝑖𝑛𝑎𝑛𝑡(𝑎,𝑏,𝑐))
2𝑎
𝑅𝑜𝑜𝑡2(𝑎, 𝑏, 𝑐) =
−𝑏−𝑆𝑞𝑢𝑎𝑟𝑒𝑅𝑜𝑜𝑡(𝐷𝑖𝑠𝑐𝑟𝑖𝑚𝑖𝑛𝑎𝑛𝑡(𝑎,𝑏,𝑐))
2𝑎
𝑄𝑢𝑎𝑑𝑟𝑎𝑡𝑖𝑐(𝑥, 𝑎, 𝑏, 𝑐) = 𝑎𝑥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.