113
112
Simultaneously execute the two previously
presented programs to calculate the surface
areas and volumes of a regular octahedron
and tetrahedron.
Express the result in three decimal places.
This example employs two previously explained programs,
and the first step is to input the specified number of
decimal places (
3 ).
Now let’s review the two original programs.
Regular octahedron
P0 Fix, 3 ,: ,?, ,A,:,2,
x
,
√
,3,x,A,
x
2
, ,
√
, 2 ,÷ ,3,
x
,A ,
x
y
,3
23 steps
Regular tetrahedron
P1 Fix, 3 ,: ,?, ,A,: ,
√
,3,x,A,
x
2 ,
,
√
, 2 ,÷ , 1,2 ,x,A ,
x
y
,3
22 steps
Total 45 steps
If the two programs are compared, it is evident that the
underlined portions are identical. If these portions are
incorporated into a common subroutine, the programs are
simplified and the number of steps required is decreased.
Furthermore, the portions indicated by the wavy line are
not identical as they stand, but if P1 is modified to:
√
, 2, ÷ ,
3 ,
x
, A,
x
y,
, 3 , ÷ , 4 , the two portions become identical.
Now the portions underlined by the straight line will be
stored as an independent routine in P9 and those
underlined with the wavy line will be stored in P8.
P9 Fix , 3 , : , ? , , A , : ,
√
, 3 ,
x
, A ,
x
2
12 steps
P8
√
, 2 , ÷ , 3 ,
x
, A ,
x
y
,
3
8 steps
After the common segments have been removed, the
remainder of the regular octahedron formula is stored in
P0, and that of the regular tetrahedron is stored in P1 Of
course, the “Prog 9” and “Prog 8” must be added to jump
to subroutines P9 and P8.
P0 Prog, 9, :, Ans,
x
, 2, , Prog, 8 9 steps
P1 Prog, 9, , Prog, 8, :, Ans, ÷, 4 9 steps
Total 38 steps
With this configuration execution jumps to program P9 at
the beginning of programs P0 and P1, three decimal
places are specified, the value for one side is entered, and
the surface area of the tetrahedron is calculated. The
expression “2x “ of the original octahedron formula was
omitted in P9, so when execution returns to P0 , “Ans x 2”
is used to obtain the surface of the octahedron. In the case
Subroutines
A program contained in a single program area is called a “
main routine” .
Often used program segments stored in other program
areas are called “ subroutines”.
Subroutines can be used in a variety of ways to help make
calculations easier.
They can be used to store formulas for repeat calculations
as one block to be jumped to each time , or to store often
used formulas or operations for call up as required.
The subroutine command is “ Prog “ followed by a number
from 0 through 9 which indicates the program area.
Prog 0 .......... Jump to program area 0
Prog 2 .......... Jump to program area 2
After the jump is performed using the Prog command,
execution continues from the beginning of the program
stored in the specified program area. After execution
reaches the end of the subroutine, the program returns to
the statement following the Prog
n
command in the original
program area. Jumps can be performed from one
subroutine to another, and this procedure is known as
“nesting “, Nesting can be performed to a maximum of 10
levels, and attempts to exceed this limit will cause an error
(Ne ERROR) to be generated. Attempting to use Prog to
jump to a program area in which there is no program stored
will also result in an error (Go ERROR).
*A Goto n contained in a subroutine will jump to the
corresponding Lbl
n
contained in that program area.
Содержание CA756
Страница 24: ...38 Parenthesis calculations...
Страница 27: ...41...
Страница 34: ...48...
Страница 36: ...50 Logarithmic and exponential functions The operations noted below cannot be performed in the BASE N mode...
Страница 40: ...54...
Страница 41: ...55 Fractions Fractions are input and displayed in the following order integer numerator denominator...
Страница 42: ...56...
Страница 45: ...59 Binary octal decimal hexadecimal conversions Negative expressions...
Страница 46: ...60 Basic arithmetic operations using binary octal decimal and hexadecimal values...
Страница 58: ...82 83 first...
Страница 79: ...125 124...
Страница 80: ...127 126...
Страница 81: ...129 128 Program Calculations...
Страница 82: ...131 130 Error Message Table...
Страница 83: ...133 132 Input Ranges of Functions...