This exercise will give you some experience using many of the basic techniques in ARM assembly language programming. Specifically, you will gain experience with a procedure call and return, passing parameters to procedures, processing arrays with pointers, auto-increment addressing, conditional branches, converting an algorithm to assembly language, and the program development cycle. This assignment will also give you some practice following the “Fast is Slow” rule and convincing yourself that it really works.
For this project, assume that a system is set up with a temperature sensor and an Analog to Digital converter to measure the Fahrenheit temperature every 1.5 hours in each 24 hour period. The A/D converter produces 8-bit binary values that represent the temperature in Fahrenheit. Temperature values range from 0 – 125 degrees Fahrenheit. The 8-bit binary values for the 16 temperatures taken each day are stored in an array of bytes named Fahrenheit_Temps. Your task will be to perform some calculations on the 16 temperature values in the array. (You will set up an array with 16 8-bit test values.)
In your first version program you calculate the rounded average of the 16 temperature values and put the result in a named memory location.
When the average version is working correctly, you develop and call a procedure that determines the minimum and maximum temperatures for the day and returns these to the mainline to be put in named memory locations.
1. Using the standard program structures write an algorithm for the program section that reads the values form the array and determines the average of the 16 byte-sized temperature values.
2. Bring up CCS and create a source program with your instructions and data sections. Note that to test your program, you will have to initialize the Fahrenheit_Temps array with 16 trial values for which you can predict the correct binary results. (If you need to declare an array that is longer than will fit on one line, you can simply put a dummy name on the next line and type more elements of the array on the next line.) Carefully determine reasonable test values to put in your Fahrenheit_Temps array, so you are testing a range of values. Make sure to put in the Header, .global, _start, etc. and load addresses into registers as in Multo.
3. When this first version of your program works, save a copy, and use this copy to work on for the second version of your program.
4. To develop the assembly language for this version of the program, assume the mainline passes the starting address of the array and the length of the array to the procedure and the procedure passes back the maximum and minimum temperatures in registers.
5. Determine the assembly language instructions you can use to implement each step in the algorithm for the procedure.
6. To your copy of the program from the first part of the project, add the needed mainline instructions needed to set up the stack, pass parameters to the procedure, call the procedure and write the returned values to named memory locations t. Also add the procedure instructions, including those to push and pop the used registers, to this copy from the first part.
7. When your complete program works correctly, print out copies of the final source code and the appropriate Debugger memory display(s) to demonstrate that the program works correctly.