Branching and looping l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 55

Branching and Looping PowerPoint PPT Presentation


  • 88 Views
  • Uploaded on
  • Presentation posted in: General

Branching and Looping. Chapter 5. Branching and Looping. 68HC12 Branch Instructions WHYP Branching and Looping Words Recursion in WHYP. Branch Displacement. Negative Branch. Branch on Z flag. Branch on Z flag. Branch on Z flag. Branch on N flag. Branch on N flag.

Download Presentation

Branching and Looping

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 looping l.jpg

Branching and Looping

Chapter 5


Branching and looping2 l.jpg

Branching and Looping

  • 68HC12 Branch Instructions

  • WHYP Branching and Looping Words

  • Recursion in WHYP


Branch displacement l.jpg

Branch Displacement


Negative branch l.jpg

Negative Branch


Branch on z flag l.jpg

Branch on Z flag


Slide8 l.jpg

Branch on Z flag


Slide9 l.jpg

Branch on Z flag


Slide10 l.jpg

Branch on N flag


Slide11 l.jpg

Branch on N flag


Slide12 l.jpg

Branch on C and V flags


Bit condition branch instruction l.jpg

Bit-Condition Branch Instruction


How many times is the instruction incb executed l.jpg

How many times is the instruction INCB executed?


Signed branch instructions l.jpg

Signed Branch Instructions


Branching and looping17 l.jpg

Branching and Looping

  • 68HC12 Branch Instructions

  • WHYP Branching and Looping Words

  • Recursion in WHYP


Whyp branching and looping words l.jpg

WHYP Branching and Looping Words

  • IF…ELSE…THEN

  • FOR…NEXT

  • BEGIN…AGAIN

  • BEGIN…WHILE…REPEAT

  • DO…LOOP


68hc12 code for l.jpg

68HC12 Code for <


Slide22 l.jpg

68HC12 Code for U<


Slide23 l.jpg

TRUE = -1

FALSE = 0


68hc12 code for and l.jpg

68HC12 Code for AND


If else then l.jpg

IF…ELSE…THEN

<cond> IF <true statements> ELSE <false statements> THEN


Slide26 l.jpg

TRUE iftest

true statements

next statements

FALSE iftest

next statements


Slide27 l.jpg

TRUE if.else.test

true statements

next statements

FALSE if.else.test

false statements

next statements


Slide28 l.jpg

IF…ELSE…THEN Example


For next loop l.jpg

FOR…NEXT Loop

n FOR <WHYP statements> NEXT


Slide31 l.jpg

: stars for ." *" next ;


For next delay loop l.jpg

FOR…NEXT Delay Loop

8 MHz clock: #ms = #clock_cycles/8 = 7.75 +1.375*N

N = (#ms - 7.75)/1.375

Ex: 50 ms delay: N = (50000 - 7.75)/1.375 = 36358


Longer delays l.jpg

Longer Delays

Note: A 10 second delay on the MC68HC12A4EVB

takes about 17 seconds because one wait state

has been added to each access to external RAM.

The 68HC11 takes over twice as long to execute

the same delay instructions.


Begin again l.jpg

BEGIN…AGAIN

BEGIN <WHYP statements> AGAIN


Begin until l.jpg

BEGIN…UNTIL

BEGIN <WHYP statements> <flag> UNTIL


Begin while repeat l.jpg

BEGIN…WHILE…REPEAT

BEGIN <words> <flag> WHILE <words> REPEAT


Sine and arcsine l.jpg

Sine and Arcsine


Slide43 l.jpg

Sine and Arcsine


Slide44 l.jpg

Sine and Cosine


Do loop l.jpg

DO…LOOP

<limit> <index> DO <WHYP statements> LOOP

Moves <limit> and <index>

to return stack

Increments <index> on return stack

and loops back to <WHYP statements>

if <index> is less than <limit>,

else pop <limit> and <index> from

return stack and exit loop


Slide47 l.jpg

DO…LOOP

The WHYP word I copies the index value from

the return stack to the top of the parameter stack.

: test( -- )

11 1 DO

I .

LOOP ;

will print

1 2 3 4 5 6 7 8 9 10


Slide48 l.jpg

DO…LOOP Example


The word leave l.jpg

The Word LEAVE

Exits a DO loop prematurely


Branching and looping51 l.jpg

Branching and Looping

  • 68HC12 Branch Instructions

  • WHYP Branching and Looping Words

  • Recursion in WHYP


Recursion in whyp l.jpg

Recursion in WHYP

n! = n * (n - 1)!


Slide53 l.jpg

Recursion in WHYP


  • Login