
Application Note
AN1218 Rev. 2
46
Appendix G — New Branch Instruction Examples
************************************************************
*
* File : BRANCH.ASM
* Description :
* Shows examples for new CPU08 branch
* instructions - CBEQ, CBEQA, CBEQX
* DBNZ, DBNZA, DBNZX
* 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
***** CBEQ - compare and branch if equal, direct
* A is predefined at $40
* Memory location $80 contains $40
* HC05 code *
LPA CMP $80 ;3,2 (A) - ($80)
BEQ LP1 ;3,2 if (A) = ($80) then
; branch to LP1
BRA LPA ; go to LPA, try again!
* HC08 code *
LP1 CBEQ $80,LPB ;5,3 if (A)-($80)=0,
; then branch to LPB
BRA LP1 ; go to LP1
* Total CPU05 cycles, bytes = 6,4
* Total CPU08 cycles, bytes = 5,3
***** CBEQA - compare and branch if equal, immediate
* A is predefined at $50
* HC05 code *
LPB CMP #$50 ;2,2 (A) - $50
BEQ LP2 ;3,2 if (A) = $50, then LP2
BRA LPB ; go to LPB
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.