Sentry Industries CA756 User Manual

Page 74

Advertising
background image

115

114

Proper utilization of subscripts shortens programs and
makes them easier to use.
Negative values used as subscripts are counted in relation
to memory zero as shown above.

Input the numbers 1 through 10 into

memories A through J .

Using standard memories
1, ,A,:,2 , ,B,: ,3 , ,C , : , 4 , ,D, : ,
5, ,E,:,6 , ,F,: ,7 , ,G , : , 8 , ,H, : ,
9, ,I,:,1 ,0, ,J, 40 steps
Using array-type memories
0, ,Z,:,Lbl ,1 ,: ,Z ,+,1 , ,A , [ , Z, ] , : ,
Lsz,Z ,:,Z ,<,1,0 ,

,Goto, 1 26 steps

In the case of using standard memories, inputting values
into memories one by one is both inefficient and time
consuming. What happens, if we want to see a value
stored in a specific memory ?
Using standard memories
Lbl , 1 , : , ? , , Z , : ,
Z, = , 1 ,

, A , , Z , = , 2 ,

, B , ,

Z, = , 3 ,

, C , , Z , = , 4 ,

, D , ,

Z, = , 5 ,

, E , , Z , = , 6 ,

, F , ,

Z, = , 7 ,

, G , , Z , = , 8 ,

, H , ,

Z, = , 9 ,

, I, , Z , = , 1 , 0 ,

, J , , 70 steps

Goto, 1
Using array-type memories
Lbl , 1 , : , ? , , Z , : , A , [ , Z , - , 1 , ] , ,
Goto, 1 16 steps
The difference is readily apparent. When using the standard
memories, the input value is compared one by one with the
value assigned to each memory (e.g.A=1 B = 2,..) .
With the array-type memories, the input value is immedi-
ately stored in the proper memory determined by “ [Z-1],
Formulas (Z-1 ,A+10, etc.) can even be used for the
subscript.

Cautions when using array-type memories

When using array-type memories, a subscript is appended
to an alphabetic character that represents a standard
memory from A through Z.
Therefore, care must be taken to prevent overlap of
memories.
The relation is as follows:

of P1, the result of P9 needs no further modification and so
is immediately displayed upon return to P1.
Calculation of the volumes is also performed in a similar
manner. After a jump is made to P8 for calculation,
execution returns to the main routines, In P0, the program
ends after the volume of the octahedron is displayed . In
P1 , however, the result calculated in P8 is divided by four
to obain the volume of the tetrahedron.
By using subroutines in this manner, steps can be
shortened and programs become neat and easy to read.
The following illustration shows the flow of the program just
presented.

By isolating the common portions of the two original
programs and storing them in separate program areas,
steps are shortened and programs take on a clear
configuration.

Using array-type memories

Up to this point all of the memories used have been
referred to by single alphabetic characters such as A, B, X,
or Y.
With the array-type memory introduced here, a memory
name (one alphabetic character from A through Z ) is
appended with a subscript such as [1] or [2].

Brackets are input by

and

.

Standard memory Array-type memory

A

A[0] C [-2]

B

A[1] C [-1]

C

A[2] C [0]

D

A[3] C [1]

E

A[4] C [2]

Advertising