Download presentation
Presentation is loading. Please wait.
1
Branching and Looping Lecture L3.2
2
Branching and Looping 68HC12 Branch Instructions
Hex-to-ASCII Subroutine Delay Loops
4
Branch Displacement
5
Negative Branch
8
How many times is the instruction INCB executed?
10
Bit-Condition Branch Instruction
13
Branching and Looping 68HC12 Branch Instructions
Hex-to-ASCII Subroutine Delay Loops
14
Branching Example 1: ; Hex to ascii subroutine 2: ; input: A = hex value 3: ; output: A = ascii value of lower nibble of input 4: hexasc 5: F anda #$0f ;mask upper nibble 6: cmpa #$ ;if A > 9 7: bls ha1 8: B adda #$ ; add $37 9: D rts ;else 10: B ha adda #$ ; add $30 11: B 3D rts Note: destination address = addr. of next instr. + displ. 0009 =
15
Branching and Looping 68HC12 Branch Instructions
Hex-to-ASCII Subroutine Delay Loops
16
Note: addr. of next instr. + displ. = destination address 000A +FFF7
; ms_delay ; input: Y = no. of milliseconds to delay ms_delay pshx 0001 CE 07CF md1 ldx # ; N = ( )/4 md2 dex ; 1 ccycle FD bne md2 ; 3 ccycle dey F bne md1 ; Y ms 000A pulx 000B 3D rts Note: addr. of next instr. + displ. = destination address 000A +FFF7 10001
17
Monitor routine to output ASCII character in A
; Delay test outa equ $FF4F ORG $800 #include hexasc.asm #include ms_delay.asm sec_delay ldy #1000 ; 1000 ms delay jsr ms_delay rts main ldab #10 ; B = 10 mn1 tba ; A = B jsr hexasc ; get ASCII value jsr outa ; output to screen bsr sec_delay ; delay 1 second decb bne mn1 ; do 10 times swi Monitor routine to output ASCII character in A
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.