
150
PROGRAMMING EXAMPLESII
Step 4: Take out MS BCD digit by ANDing the accumulator with F0H.
Step 5: Rotate the accumulator four times to shift the digit to lower nibble.
Step 6: Store it in R7 and return.
; Subroutine to unpack a BCD number.
UNPACK: MOV A, 30H ; get packed BCD number in the accumulator
ANL A, #0FH ; take out lower nibble
MOV R6, A ; store lower nibble in R6
MOV A, 30H ; get unpacked BCD number again
ANL A, #0F0H ; take out higher nibble
RR A ; shift it to the lower nibble
RR A
RR A
RR A
MOV R7, A ; store it in R7
RET
Later we shall fi nd that the SWAP instruction may replace four RR ...