Question :
Suppose you have two arrays of 8-bit signed integers P[i] and Q[i] for 0 = i < N. Write a subroutine mdiff that will find the maximum of (Q[i]-P[i]) for 0 = i < N.
A pointer to the array P is passed in register X and a pointer to the array Q is passed in register Y. The number of elements in each array N is passed in accumulator A.
The result should be returned in accumulator A, overwriting the value N. (You can assume that the values of P(i) and Q(i) lie between -63 and +63 so that their difference is always representable as an 8-bit signed quantity)
(i) You are required to save and restore any accumulators and/or registers used by the subroutine (other than A). The pointers in X and Y should be returned unchanged to the calling program.
(ii) The contents of the arrays P and Q should not be changed. (HSC12 Assembly language)
(a) Draw the stack frame as seen by the subroutine
(b) Write the code for the subroutine