|
Section 11: Branching and Looping164
|
|
The cc portion of the number
tells the calculator how you wish to count. Current counter value
iiiii is incremented or
decremented by the increment value of
cc. If you do not specify
a cc value, the HP-41C assumes
you wish to count by ones (cc=01).
A cc value must be specified as
two digits (e.g., 01, 03, 55).
|
|
Increment and Skip if Greater
|
|
Each time ISG is executed, it first
increments iiiii by
cc. It then tests to see if
iiiii is greater than
fff. If it is then the HP-41C
skips the next line in the program.
|
|
So, if you stored the number 100.20001 in storage register
R10, the
ISG 10 instruction would begin counting at
100, would count up until the counter was greater than 200, and it
would increment by 1 each time the loop was executed.
|
|
|
Contents of storage register
R10 =
100.20001
|
|
|
Execution of
ISG 10 would:
|
|
|
|
Start counting at 100.
|
|
|
Increment by 1.
|
|
|
Test to see if counter is greater than 200.
|
|
|
After one execution or pass through the loop,
R10 would be 101.20001. After 10
executions or passes through the loop,
R10 would be 110.20001. Each time
ISG 10 is executed it checks to see if the counter
is greater than 200. When it is greater than 200, it skips the next line of
the program. You will see how skipping the next line in the program
is useful in a moment.
|
|
If you execute ISG from the keyboard, it
simply increments the specified register just like it would in a
program, but no program lines are executed or skipped.
|
|
Decrement and Skip if Equal
|
|
Each time DSE is executed, it first
decrements iiiii by
cc. It then tests to see if
iiiii is equal to (or less than)
fff. If it is then the HP-41C
skips the next line in program memory.
|
|
So, if you stored the number 100.01001 in storage register
R11, the
DSE instruction would begin counting at
100, would count down until the counter was equal to (or less than) 10,
and it would decrement by 1 each time the loop was executed.
|
|
|
Contents of storage register
R11 =
100.01001
|
|
|
Execution of
DSE 11 would:
|
|
|
|
Start at 100.
|
|
|
Decrement by 1.
|
|
|
Test to see if counter is equal to
(or less than) 10.
|
|
|
Remember, in a program when the final vlaue is obtained, the HP-41C
skips the next line in the program. You will see how this is useful
later.
|