
188
PROGRAMMING EXAMPLESIII
DJNZ R7, XCHNG ; continue for all terms
RET ; over
; Name: CHANGE
; Function: Interchange contents of two locations as pointed by R0 and R1
; Input: R0, R1 point the pair to be interchanged
; Output: Pointed contents interchanged, the accumulator remains unchanged
; Calls: None
; Uses: A, R0, R1
CHANGE: XCH A, @R0 ; get front term in A
XCH A, @R1 ; store it at rear and get rear term in A
XCH A, @R0 ; store it at front
RET ; interchanging of one pair complete
Observe how all important details of the subroutine are documented at its beginning.
13.4 | HEX to BCD Conversion
Example 13.4 ...