branching and looping
Download
Skip this Video
Download Presentation
Branching and Looping

Loading in 2 Seconds...

play fullscreen
1 / 17

Branching and Looping - PowerPoint PPT Presentation


  • 100 Views
  • Uploaded on

Branching and Looping. Lecture L3.2. Branching and Looping. 68HC12 Branch Instructions Hex-to-ASCII Subroutine Delay Loops. Branch Displacement. Negative Branch. How many times is the instruction INCB executed?. Bit-Condition Branch Instruction. Branching and Looping.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Branching and Looping' - marcell-connor


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
branching and looping1
Branching and Looping
  • 68HC12 Branch Instructions
  • Hex-to-ASCII Subroutine
  • Delay Loops
branching and looping2
Branching and Looping
  • 68HC12 Branch Instructions
  • Hex-to-ASCII Subroutine
  • Delay Loops
slide14

Branching Example

1: ; Hex to ascii subroutine

2: ; input: A = hex value

3: ; output: A = ascii value of lower nibble of input

4: 0000 hexasc

5: 0000 84 0F anda #$0f ;mask upper nibble

6: 0002 81 09 cmpa #$9 ;if A > 9

7: 0004 23 03 bls ha1

8: 0006 8B 37 adda #$37 ; add $37

9: 0008 3D rts;else

10: 0009 8B 30 ha1 adda #$30 ; add $30

11: 000B 3D rts

Note: destination address = addr. of next instr. + displ.

0009 = 0006 + 03

branching and looping3
Branching and Looping
  • 68HC12 Branch Instructions
  • Hex-to-ASCII Subroutine
  • Delay Loops
slide16

; ms_delay

; input: Y = no. of milliseconds to delay

0000 ms_delay

0000 34 pshx

0001 CE 07CF md1 ldx #1999 ; N = (8000 - 5)/4

0004 09 md2 dex ; 1 ccycle

0005 26 FD bne md2 ; 3 ccycle

0007 03 dey

0008 26 F7 bne md1 ; Y ms

000A 30 pulx

000B 3D rts

Note: addr. of next instr. + displ. = destination address

000A

+FFF7

10001

slide17

; 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

ad