Copyright L
EXIBOOK
2002
- 63 -
GB
As can be seen, the second displayed value (which should be 2) in A[2] is incorrect. This problem has
occurred because memory A[2] is the same as memory C.
A
B
C
D
E
F
A[1]
A[2]
A[3]
A[4]
A[5]
The content of memory C (A[2]) is decreased from 5 to 0 in steps of 1.
Therefore, the content of memory A[2] is displayed as 0.
4.8.3 Application of the array-type memories
It is sometimes required to treat two different types of data as a single group. In this case, memories for
data processing and those for data storage should be kept separate.
Example: store data x and y in memories. When an x value is input, the corresponding y value is dis-
played. There will be a total of pieces of data.
Example program 1
Memory A is used as the data control memory, and memory B is used for temporary storage of the x data.
The x data are stored in memories C[1] (memory D) through C[15] (memory R), and the y data are stored
in memories C[16] (memory S) through C[30] (memory Z(7)).
1,
→
, A, :, Defm, 7, :,
Lbl, 1, :, ?,
→
, C, [, A, ], :,
?,
→
, C, [, A, +, 1, 5, ], :,
Isz, A, :, A, =, 1, 6,
⇒
, Goto, 2, :, Goto, 1, :,
Lbl, 2, :, 1, 5,
→
, A, :, ?,
→
, B, :,
B, =, 0,
⇒
, Goto, 5, :,
Lbl, 3, :, B, =, C, [, A, ],
⇒
, Goto, 4, :,
Dsz, A, :, Goto, 3, :, Goto, 2, :,
Lbl, 4, :, C, [, A, +, 1, 5, ],:, Goto, 2, :,
Lb, 5
98 steps
In this program, memories are used as follows:
x date:
C[1]
C[2]
C[3]
C[4]
C[5]
C[6]
C[7]
C[8]
D
E
F
G
H
I
J
K
C[9]
C[10]
C[11]
C[12]
C[13]
C[14]
C[15]
L
M
N
O
P
Q
R
y date:
C[16]
C[17]
C[18]
C[19]
C[20]
C[21]
C[22]
C[23]
S
T
U
V
W
X
Y
Z
Z:
C[24]
C[25]
C[26]
C[27]
C[28]
C[29]
C[30]
Z(1)
Z(2)
Z(3)
Z(4)
Z(5)
Z(6)
Z(7)
Example program 2: The same memories are used as in Example 1, but two types of memory names are
used and the x and y data kept separate
1,
→
, A, :, Defm, 7, :,
Lbl, 1, :, ?,
→
, C, [, A, ], :,
?,
→
, R, [, A, ], :,
Isz, A, :, A, =, 1, 6,
⇒
, Goto, 2, :, Goto, 1, :,
Lbl, 2, :, 1, 5,
→
, A, :, ?,
→
, B, :,
B, =, 0,
fi
, Goto, 5, :,
Lbl, 3, :, B, =, C, [, A, ],
⇒
, Goto, 4, :,
Dsz, A, :, Goto, 3, :, Goto, 2, :,
Lbl, 4, :, R, [, A, ], :, Goto, 2, :,
Lb, 5
92 steps
Memories are used as follows:
x date:
C[1]
C[2]
C[3]
C[4]
C[5]
C[6]
C[7]
C[8]
D
E
F
G
H
I
J
K
C[9]
C[10]
C[11]
C[12]
C[13]
C[14]
C[15]
L
M
N
O
P
Q
R