Post Reply 
(41CX, DM41X): Assign User Keys Through a Program
08-07-2022, 05:52 PM
Post: #1
(41CX, DM41X): Assign User Keys Through a Program
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:
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
Visit this user's website Find all posts by this user
Quote this message in a reply
08-07-2022, 08:36 PM
Post: #2
RE: (41CX, DM41X): Assign User Keys Through a Program
It looks like you're not using Reg 00 again; so instead of STO 00, GTO IND 00, can you just do GTO IND X? (Press the decimal point before X to specify that you're not doing a numbered register.)

Instead of AVIEW, RTN, how about just PROMPT?

http://WilsonMinesCo.com  (Lots of HP-41 links at the bottom of the links page, at http://wilsonminesco.com/links.html#hp41 )
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)