Question
Lab 8 - HCS12 Assembly & C Programming Objectives: • Practice HCS12 assembly subroutines • Practice C programming Introduction: In this lab, students will have hands-on practice creating subroutines in the HCS12 assembly. They will practice the different ways of passing the input parameters and returning values to/from the subroutine. In addition, students will practice calling a subroutine from another subroutine and practicing writing C code. Task 1 Write an assembly subroutine that calculates the average value of an array of 16-bit integers, equivalent to the C code below. Use registers to pass the function arguments to the subroutine. ° for the array pointer, use register X ° for the size of the array, use register B ° for the return value, use register D int average( int *array, int size ) { int sum = 0; for(int i = 0; i