The Huang textbook Example 5.4 includes a function with the prototype, unsigned
ID: 3792142 • Letter: T
Question
The Huang textbook Example 5.4 includes a function with the prototype, unsigned long int FindSqr (unsigned long int). This function calculates the squareroot of a 32-bit integer. The Codewarrior Examples library, under Chapter OS, on our lab computers has the C program; eg05_04. c. A slightly modified version of this program is listed below for your perusal. Just like you ran other C programs in the lab under Full Chip Simulation, run this C program and include screen dumps for the text window (that shows the program code) and debug window (that shows the result x1). Check on your calculator if the result is the closest integer value.//C program to compute the squareroot of a 32-bit number//Han Way Huang Text code: eg05_04.c//Minor modification done by K. Mondal on 2/5/2015//Variable x1 is turned into a global variable//#include "hcs12.h" unsigned long int findSqr (unsigned long int xval); unsigned long int x1; void main (void){x1 = findSqr(234567); while(1);} unsigned long int findSqr (unsigned long int xval) {unsigned long int mask, temp, sar; unsigned int ix; mask = 0x8000;//Initialize mask for making bit value guess sar = 0; for (ix = 0; ix = 1;} if ((xval - (sar * ssr)) > ((sar + 1) * (sar + 1) = xval)) sar + = 1; return sar;Explanation / Answer
Follow the below steps for the solution of the given lab exercise.
* "hcs12.h" might be an internal header file so external members cannot debug your code.
* open your notepad, write the code given, save the file with ".c" extension
* Navigate to the program folder
* use the command "gcc filename.c" to compile your c program
* now use the command "./a.out" to execute the program
* No need to provide any input as you explicitly provided the input as "234567"
* Take the screenshot of your terminal
* Check if the answer displayed on the terminal is equal to 484.32 (Square root of 234567 )
Attach the screenshot of the terminal and calculated answer to your exercise report.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.