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

Loading in 2 Seconds...

play fullscreen
1 / 55

Branching and Looping - PowerPoint PPT Presentation


  • 120 Views
  • Uploaded on

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.

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' - kezia


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 looping2
Branching and Looping
  • 68HC12 Branch Instructions
  • WHYP Branching and Looping Words
  • Recursion in WHYP
branching and looping17
Branching and Looping
  • 68HC12 Branch Instructions
  • WHYP Branching and Looping Words
  • Recursion in WHYP
whyp branching and looping words
WHYP Branching and Looping Words
  • IF…ELSE…THEN
  • FOR…NEXT
  • BEGIN…AGAIN
  • BEGIN…WHILE…REPEAT
  • DO…LOOP
slide23
TRUE = -1

FALSE = 0

if else then
IF…ELSE…THEN

IF ELSE THEN

slide26
TRUE iftest

true statements

next statements

FALSE iftest

next statements

slide27
TRUE if.else.test

true statements

next statements

FALSE if.else.test

false statements

next statements

for next loop
FOR…NEXT Loop

n FOR NEXT

for next delay loop
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
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
BEGIN…AGAIN

BEGIN AGAIN

begin until
BEGIN…UNTIL

BEGIN UNTIL

begin while repeat
BEGIN…WHILE…REPEAT

BEGIN WHILE REPEAT

do loop
DO…LOOP

DO LOOP

Moves and

to return stack

Increments on return stack

and loops back to

if is less than ,

else pop and from

return stack and exit loop

slide47
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

the word leave
The Word LEAVE

Exits a DO loop prematurely

branching and looping51
Branching and Looping
  • 68HC12 Branch Instructions
  • WHYP Branching and Looping Words
  • Recursion in WHYP
recursion in whyp
Recursion in WHYP

n! = n * (n - 1)!

ad