#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 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
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
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.
|