Question: (a) (b) Write an PIC18 instruction sequence to implement the following mathematical expression. R = (P-Q) The variables P and Q are single-byte numbers
(a) (b) Write an PIC18 instruction sequence to implement the following mathematical expression. R = (P-Q) The variables P and Q are single-byte numbers stored at file registers 0x010 and 0x020, respectively. The double-byte answer, R should be stored at file registers 0x150 and Ox151 using little endian format. Write a subroutine to compare two 8-bit unsigned numbers stored in PRODH and PRODL, and return the smallest between the two in PRODL to the main program. The subroutine should be named getMIN and should start at address 0x003000. Refer to Figure 2 for an example of how the subroutine could be used in main program. SETF _next MOVFF ; partial coding of a main program showing how the subroutine ; getMIN is used TBLRD*+ MOVFF CALL MOVEF DECFSZ BRA ... min_num, A min_num, PRODL [5 Marks] TABLAT, PRODH getMIN, FAST PRODL, min_num lp_cnt, F, A _next - [5 Marks] ; initialize ; put current min into PRODL Figure 2: Incomplete assembly program for Question 3(b). ; copy element into PRODH ; call subroutine to get min number ; update current min
Step by Step Solution
3.42 Rating (161 Votes )
There are 3 Steps involved in it
Based on Part a of the question provided in the image the task is to write a PIC18 assembly language instruction sequence that implements the mathemat... View full answer
Get step-by-step solutions from verified subject matter experts
