$9
File I/O and Floating-Point Numbers
Write an ARMv8 assembly language program to compute the sine and cosine of an angle given in degrees using the series expansions shown below. Use double precision floating-point numbers and only allow angles between 0 and 90 degrees. The program will read a list of input values from a file whose name is specified at the command line. The input values will be in binary format; each number will be double precision (and thus each is 8 bytes long). Read from the file using system I/O (i.e. generate an exception using the svc instruction). Process the input values one at a time using a loop (be sure to detect end-of-file correctly), calculate the sine and cosine, and then use printf() to print out the input value and its corresponding sine and cosine values in table form (i.e. in columns, with column headings) to the screen (standard output). Print out all values with a precision of 10 decimal digits to the right of the decimal point.
You can compute the sine and cosine according to the following series expansions:
where x is the angle in radians. Continue to accumulate terms until the absolute value of the term is less than 1.0e-10. You may need the constant π/2 = 1.57079632679489661923 to help convert the angle from degrees to radians.
Run your program using the input binary file supplied on D2L. Capture its execution using the script UNIX command, and name the output file script.txt.
New Skills needed for this Assignment:
• Use of system I/O (exceptions) to open and read an input binary file
• Understanding and use of floating-point single and double formats
• Use of floating-point instructions to do simple calculations
• Use of floating-point branching instructions
Submit the following:
1. Your assembly source code and script via electronic submission. Use the Assignment 6 Dropbox Folder in D2L to submit electronically. Your TA will assemble and run your program to test it. Name your program a6.asm and the script as script.txt.
Computing Machinery I
Assignment 6 Grading
Student:__________________________________________
Command line arguments 2 ______
Loop to read in data 2 ______
File I/O using traps 4 ______
Sine routine 4 ______
Cosine routine 4 ______
Screen output using printf() 2 ______
Correct use of floating-point instructions 2 ______
Script showing I/O 2 ______
Complete documentation and commenting 4 ______
Design quality 2 ______
Total 28 ______ _____%