#L7

Q: How can I loop through a short set of code 10,000 times?




Using the Program Mode to repeat sequences of vectors

First of all, you must employ Program Mode (invoked by "Sequencing" under Run Setup). Your objective is to set a counter to n which is the number of times you wish to repeat a sequence of vectors, and then execute this segment of test vectors n times. Our examples use "Hex" as the radix selected for address from the View drawer.

Begin by filling the entire program space with NOOP's so that the vectors will simply execute in a sequential fashion. This you do by pulling down the Vector drawer and selecting Program Fill + NOOP + Fill It. Did you notice how quickly the HILEVEL HRISC processor filled your vector program?

Next go to the vector which is the starting point of the repetitive vectors. Three vectors prior to that, load a count value using the LOAD and LOADX commands (LOAD takes care of the three least significant hex digits, while LOADX accesses the most significant hex digit -- forming a 16K repeat counter since the most significant digits must be three or less). Then for the two last vectors in the loop use the instructions DEC (decrement) and CJMP [ADDRESS] (conditional jump), where ADDRESS is the hex address of the first vector in the loop that follows the LOAD process. Let us illustrate this with an example.

Consider the following vector segment:

23A NOOP H 00 1 AXXX 0 0 10 00A1 1
23B NOOP L 11 1 XXXX 0 0 10 BF00 1
23C NOOP H 10 1 AXXX 0 0 10 BF00 1
23D NOOP H 00 0 BXXX 0 0 10 BF00 1
23E NOOP L 00 1 AXXX 0 0 10 BF00 1
23F NOOP L 00 0 AXXX 0 0 10 BF00 1
240 NOOP L 00 1 AXXX 0 0 10 BF00 1
241 NOOP L 00 0 AXXX 0 0 10 BF00 1
242 NOOP L 00 1 AXXX 0 0 10 BF00 1
243 NOOP L 00 0 AXXX 0 0 10 BF00 1
244 NOOP L 00 1 AXXX 0 0 10 BF00 1
245 NOOP L 00 0 AXXX 0 0 10 BF00 1
246 NOOP L 00 1 AXXX 0 0 10 BF00 1
247 NOOP L 00 0 AXXX 0 0 10 BF00 1
248 NOOP L 00 1 AXXX 0 0 10 BF00 1
249 NOOP L 00 0 AXXX 0 0 10 BF00 1
24A NOOP L 00 1 AXXX 0 0 10 BF00 1
24B NOOP L 00 0 AXXX 0 0 10 BF00 1
24C NOOP L 00 1 AXXX 0 0 10 BF00 1
24D NOOP L 00 0 AXXX 0 0 10 BF00 1
24E NOOP H 11 1 AXXX 0 0 10 BF00 1
24F NOOP H 00 0 XXXX 1 1 11 0000 1

  Vector example for Repeat looping

Here, vectors 23E and 23F are repeated eight times. While this normally may not be worth the expansion effort, it certainly would be if the vectors were repeated a hundred thousand times or more, and the mechanism for doing the expansion is the same. The following shows the end result:

23B LOADX 0  L 11 1 XXXX 0 0 10 BF00 1 23C LOAD  8  H 10 1 AXXX 0 0 10 BF00 1 23D NOOP     H 00 0 BXXX 0 0 10 BF00 1 23E DEC      L 00 1 AXXX 0 0 10 BF00 1 23F CJMP 23E L 00 0 AXXX 0 0 10 BF00 1 24E NOOP     H 11 1 AXXX 0 0 10 BF00 1

     Vector example: eight repeats


The savings here is only 14 vectors. However, if the vectors were repeated 10,000 times, the savings would be 19,998 vectors and the pattern generator program would look like this:*

23B LOADX 2  L 11 1 XXXX 0 0 10 BF00 1 23C LOAD 710 H 10 1 AXXX 0 0 10 BF00 1 23D NOOP     H 00 0 BXXX 0 0 10 BF00 1 23E DEC      L 00 1 AXXX 0 0 10 BF00 1 23F CJMP 23E L 00 0 AXXX 0 0 10 BF00 1 24E NOOP     H 11 1 AXXX 0 0 10 BF00 1

     Vector example: 10,000 repeats


If you use the $L command in Cae-Link you can compress redundant vectors automatically during the translation process. The Cae-Link translator will provide a PRG file along with the translated vector file, containing all of the vector loops needed for execution.

For further information about the Program Mode, refer to the 1992 Application Note #20 TopazV and ETS Pattern Generator Techniques. Learn to make CALLs to subroutines, repeat a single vector and to use Pattern Matching as the condition for jumps. This note is available from your HILEVEL representative.

________________________________

*Note: for the ETS570 and later systems, the repeat counter has been improved so that LOADX and PAGE use a 64K page boundary, not just 16K. This reduces the number of loops needed.

QL7.zip is a zipped Word file of this Q'nApp.


Click your browser's Back button to return to the Q'nApps index.

© 1999 HILEVEL Technology Inc.