- 58 -
Copyright L
EXIBOOK
2002
GB
In this program, a 0 is first stored in memory B to clear it for calculation of the sum. Next, the value input
by “? I A” is stored in memory A by “A=0
⇒
” and it is determined whether or not the value stored in
memory A equals zero. If A=0, goto 2 causes execution to jump to Lbl 2. If memory A does not equal 0,
Goto then Goto 1 returns execution to Lbl 1.
Execution from Lbl 2 will display the sum that has been stored in memory B. Actually, the display
command “4” is inserted following B, but here it can be omitted.
The following illustration shows the flow of the program:
4.7.4 Count jumps
The count jumps cause the value in a specified memory to be increased or decreased by 1. If the value does
equal 0, the following statement is skipped, and the statement following the next “:” or “
” is executed.
The “Isz” command is used to increase the value in memory by 1 and decide the subsequent execution,
while the “Dsz” command is used to decrease the value by 1 and decide.
Example:
Increase memory A by one ................... Isz A
Decrease memory B by one …............... Dsz B
Program 1, 0,
→
, A, :, 0,
→
, C, :,
Lbl, 1, :, ?,
→
,B, :, B, +, C,
→
, C, :,
Dsz, A, :, Goto, 1, :, C,
÷
, 1, 0
32 steps
In this program, first 10 is stored in memory A, and 0 is stored in memory C. Memory A is used as the
“counter” and countdown is performed the specified number of times by the Dsz command. Memory C is
used to store the sum of the inputs, and so first must be cleared by inputting 10. The numeric value input
in response to “?” is stored in memory B, and then the sum of the input values is stored in memory C by
“B+C
→
C”.
The statement Dsz A then decreases the value stored in memory A by 1. If the result does not equal 0, the
following statement, Goto 1 is executed. If the result equals 0, the following Goto 1 is skipped and “C
÷
10”
is executed.
(A
≠
O)
(A
=
O)
A = O
⇒
Gogo 2 : A+B
→Β
: Goto 1
Lbl 1 : ?
→
A
(A=O)
(A
≠
O)
Lbl 2 :B
Isz Memory name: Statement
Statement
Memory contents h0
Memory contents = 0
{
:
}
Dsz Memory name: Statement
Statement
Memory contents
≠
0
Memory contents = 0
{
:
}