.Several CY545 commands control program branching and flow while the CY545 is executing a program from external memory. These commands normally are used only within a program, not as direct CY545 commands. The CY545 will however execute the commands in the direct mode, but the result may be different than if the commands were run from a program. The commands are:
J Addr..........Jump to byte location of current page
L Cnt,Addr......Loop to byte address for count times
Z Cnt16,Addr....Zloop to byte address for count times
In addition to the above commands, the Y command, when executed from a program, provides a 16 bit jump that can reach any address of the external memory.
The above listed commands all use an 8 bit address value. This restricts the range of addresses to the 256 bytes of the current memory page. When a jump is taken, the lower byte of the current address pointer is replaced by the 8-bit address parameter value, and program execution continues at this new 16-bit address. If one of the above commands lies on a page boundary, the address pointer is incremented before the command is executed, so the branch would be taken into the new page of the memory, not the previous page that started the command.
The Jump command simply provides a short version of the branch function. It can reach any address on the current memory page.
The Loop command provides a repeated branch, with a specified number of iterations. Both parameters are byte values, so a loop may be repeated 255 times, and the branch must be to an address on the current page.
The Zloop command also provides a repeated branch. However, the repeat count is a 16-bit value, so the Zloop may be repeated up to 65535 times. The branch is still restricted to an address on the current page.
For both loop commands, the instruction following the loop is executed when the loop count is exhausted.
The combination of the Loop and Zloop commands provides two levels of nesting to loops. Only one of each type of loop may be active at a time. That is, a number of loops may reside within one zloop, or a number of zloops may reside within one loop.
However, one loop may not reside within another loop, and one zloop may not reside within another zloop. This is shown below:
![[Zloops within a Loop]](gif/545-18.gif)
![[Loops within a Zloop]](gif/545-19.gif)
Recall that the CY545 also supports a branch command using the bit instructions, the Til command. It tests the I/O signals against the specified bit parameter value, and jumps if the values do not match. Otherwise execution continues with the instruction after the Til command.
00 Contents ..|..
01 Intro ..|..
02 Pins & Packages ..|..
03 Cmd Interfaces ..|..
04 Commands..|..
05 Motor Cmds
06 Bit Cmds..|..
07 Memory Cmds..|..
08 Prog Branch Cmds..|..
09 Mode Cmds ..|..
10 Misc Cmds
11 Circuits ..|..
12 External Memory ..|..
13 Thumbwheel Switch
..|.. 14 Output
Display ..|..
15 Proto Boards
16 Timing & Control
..|.. 17 Rate
Tables ..|..
18 Electrical Specs ..|..
19 Examples ..|..
20 Up & Running
Back to CY545 Data Sheet
© 1988 - 1999 Cybernetic Micro Systems, Inc.
All rights reserved.
CY545 Manual 22MAR99