Sunday, October 2, 2022

Swiss Micros DM41X: Setting Up Keys Through a Program

Swiss Micros DM41X:  Setting Up Keys Through a Program


Assigning User Keys Through a Program


On the HP 41/DM 41 family, it is possible to store programs or commands in a program (see Caution below).


ASN vs PASN


Both ASN and PASN assigns a user key.  ASN is not a programmable command, but PASN is.  


ASN will prompt for a key with the program or command in the alpha register. 


PASN is a programmable command with the following syntax:


^T  (program or command name)

(key code)

PASN


The key codes start in the upper left hand corner of the classic HP 41C calculators.  If you are using a Swiss Micros version, please keep in mind that the keyboard is different from the classic HP 41C but the key codes are retained.


Some common user keyboard key codes are:

[ Σ+ ] 11

[ 1/x ] 12

[ √x ] 13

[ LOG ] 14

[ LN ] 15


[x<>y] 21

[ R↓ ] 22

[SIN] 23

[COS] 24

[TAN] 25


[ENTER↑] 41

[ - ] 51

[ + ] 61

[ × ] 71

[ ÷ ] 81


Shifted user keys have a negative value, for example:

[ (shift) ] [ Σ+ ] ( Σ- )  -12

[ (shift) ] [ 1/x ] (y^x)  -13

 and so on.


Clearing Assigned Keys


To clear a single user key, assign a blank alpha string to it.  This works for both ASN and PSAN.  


You can clear all the keys by the CLKEYS command. (see Caution below).


Caution:  Unless modifications or additional ROMs are added, the commands PASN and CLKEYS are not available on the HP 41C and the HP 41CV.  The commands are available on the HP 41CX, DM41X,  DM 41, and DM 41L.  



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


Swiss Micros DM41X Program UFX


(^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


That is all this time, see you next time!


Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 



HP 20S: Gamma Function Approximation (Stirling's Formula)

HP 20S:  Gamma Function Approximation (Stirling's Formula) Introduction The gamma function uses the approximation sequence: Let t = x + ...