08-07-2022, 05:52 PM
Introduction - Template
Give the user a choice to clear or load the user keys:
LBL ^T (main name of the program)
^T 0 CLR 1 LOAD
PROMPT
STO 00
GTO IND 00
Fortunately we can use indirect addressing with the GTO command.
This section clears all the keys. I put a DONE message to tell the user that the process is done.
LBL 00
CLRKEYS
^T DONE
AVIEW
RTN
This section loads the commands and programs to user keys. Detailed programs will follow.
LBL 01
^T (program or command name)
(key code)
PASN
...
RTN
Now for the programs and calculations created:
LBL ^T (program or command name)
(contents)
RTN
...
END
Add an END command after the last RTN.
The Program UFX
The program UFX presents the user with two options: enter 0 to clear all the user keys. Entering 1 loads the following functions:
SSPH: Surface area of a sphere. Assigned to the user key [ Σ+ ], key code 11.
Surface area of a sphere = 4 * π * x^2
VSPH: Volume of a sphere. Assigned to the user key [ x<>y ], key code 21.
Volume of a sphere = 4/3 * π * x^3
STOR: Surface area of a torus. Assigned to the user key [ 1/x ], key code 12.
Surface area of a torus = 4 * π * y * x
y = larger radius, x = smaller radius
VTOR: Volume of a torus. Assigned to the user key [ R↓ ], key code 22.
Volume of a torus = 2 * π^2 * y * x^2
y = larger radius, x = smaller radius
Code:
Source for the Torus formulas:
Mathematics Program Library: Sinclair Enterprise Programmable Sinclair Radionics Inc. New York; Cambridgeshire, London. 1975
Give the user a choice to clear or load the user keys:
LBL ^T (main name of the program)
^T 0 CLR 1 LOAD
PROMPT
STO 00
GTO IND 00
Fortunately we can use indirect addressing with the GTO command.
This section clears all the keys. I put a DONE message to tell the user that the process is done.
LBL 00
CLRKEYS
^T DONE
AVIEW
RTN
This section loads the commands and programs to user keys. Detailed programs will follow.
LBL 01
^T (program or command name)
(key code)
PASN
...
RTN
Now for the programs and calculations created:
LBL ^T (program or command name)
(contents)
RTN
...
END
Add an END command after the last RTN.
The Program UFX
The program UFX presents the user with two options: enter 0 to clear all the user keys. Entering 1 loads the following functions:
SSPH: Surface area of a sphere. Assigned to the user key [ Σ+ ], key code 11.
Surface area of a sphere = 4 * π * x^2
VSPH: Volume of a sphere. Assigned to the user key [ x<>y ], key code 21.
Volume of a sphere = 4/3 * π * x^3
STOR: Surface area of a torus. Assigned to the user key [ 1/x ], key code 12.
Surface area of a torus = 4 * π * y * x
y = larger radius, x = smaller radius
VTOR: Volume of a torus. Assigned to the user key [ R↓ ], key code 22.
Volume of a torus = 2 * π^2 * y * x^2
y = larger radius, x = smaller radius
Code:
Code:
(^T: alpha string indicator)
01 LBL ^T UFX
02 ^T 0 CLR 1 LOAD
03 PROMPT
04 STO 00
05 GTO IND 00
06 LBL 00
07 CLRKEYS
08 ^T DONE
09 AVIEW
10 RTN \\ RTN outside a subroutine stops the program
11 LBL 01 \\ assign the keys first, add the programs later
12 ^T SSPH
13 11
14 PASN
15 ^T VSPH
16 21
17 PASN
18 ^T STOR
19 12
20 PASN
21 ^T VTOR
22 22
23 PASN
24 ^T DONE
25 AVIEW
26 RTN \\ this ends the loading processing, the detialed subroutines follow
27 LBL ^T SSPH
28 X↑2
29 PI
30 *
31 4
32 *
33 RTN
34 LBL ^T VSPH
35 3
36 Y↑X
37 4
38 *
39 3
40 /
41 PI
42 *
43 RTN
44 LBL ^T STOR
45 *
46 PI
47 X↑2
48 *
49 4
50 *
51 RTN
52 LBL ^T VTOR
53 X↑2
54 *
55 PI
56 X↑2
57 *
58 2
59 *
60 RTN
61 END \\ we want to end the program with END
Source for the Torus formulas:
Mathematics Program Library: Sinclair Enterprise Programmable Sinclair Radionics Inc. New York; Cambridgeshire, London. 1975