Application Note
AN1218 Rev. 2
52
Appendix J — Five MiscellaneousCPU08 InstructionsIncluding BCD, Divide,
and CCR Operations
************************************************************
*
* File : MISCINST.ASM
* Description :
* Shows examples for 5 misc CPU08 instructions
* that include BCD, Divide, and CCR operations
* They are DAA, NSA, DIV, TAP, TPA
* Notes: Comments to the right of some instructions
* give numbers.
* CPU05 - 1st # is CPU05 cycle count
* 2nd # is instruction byte count
* CPU08 - 1st # is CPU08 cycle count
* 2nd # is instruction byte count
* Please consult the CPU08 Reference Manual
* for further details on these instructions
* Code is written for educational
* purposes only
*
************************************************************
ORG $200
***** DAA - decimal adjust accumulator
START LDA #$26 ; A
←
$26, a BCD #
ADD #$37 ; A
←
$37 + (A)
; A = $5D, a hex #
DAA ; (A) = 63 = (26 + 37)
; the hex #, 5D, has been
; adjusted to the BCD #, 63
***** NSA - nibble swap accumulator
* A is predefined at $37
* When finished A will be at $73
* HC05 code *
TAX ;2,1 X
←
(A)
ROLX ;3,1 rotate left X
ROLA ;3,1 rotate left A
ROLX ;3,1 rotate left X
ROLA ;3,1 rotate left A
ROLX ;3,1 rotate left X
ROLA ;3,1 rotate left A
ROLX ;3,1 rotate left X
ROLA ;3,1 rotate left A
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.