01-18-2018, 11:54 PM

Hello everyone,

I recently bought a classic 1983 Hp 12c. I like it a lot, it's very cute.

But there are no trigonometric functions on this calculator, so I started to search information for programming those functions on this calculator.

The information I found in these forums is very good, mainly by Gerson Barbosa and Valentin Albillo, but it is geared towards the new incarnation of the Hp 12c that has more memory and is faster. I need a usable system for the Hp 12c that has only 99 steps of program memory.

I have these goals:

1. Of the 99 steps of program memory, 75% at most should be filled with the trigonometric functions, and the other 25% should remain free for programming the typical occasional functions.

2. Constants for computing the approximation polynomials should be hardcoded in those 75 steps,

so financial and statistical registers would be free for other things.

3. Only the [R/S] key should be used for executing all six trigonometric functions. The use of GOTO XX [R/S] for dispatching to different functions breaks the rythm (mentally and physically) of the human interface. This is what I don't like of the Hp 12c, having to remember all those goto addresses because there are no labels. So there should be dispatching code hardcoded in those 75 steps.

DESCRIPTION OF A SYSTEM

Once the user puts a number in the X register and presses [R/S], one of three functions gets called depending on the nature of the number x.

If 0 < x < 1

then the COMPLEMENT function gets executed, it returns the same number in the Y register, and SQRT(1-x*x) in the X register.

If x>=1

then the SINCOS function gets executed, it considers x as an angle measured in degrees, and returns SIN(x) in the Y register, and COS(x) in the X register.

If x<0

then the ARCTAN function gets executed, returns ARCTAN(-x) in the X register.

EXAMPLES

sin(25.3) ::: 25.3 [R/S] [X<>Y] --> 0.427358

cos(25.3) ::: 25.3 [R/S] --> 0.904083

tan(25.3) ::: 25.3 [R/S] [/] --> 0.472698

asin(0.3) ::: 0.3 [R/S] [/] [CHS] [R/S] --> 17.458 degrees

acos(0.4) ::: 0.4 [R/S] [X<>Y] [/] [CHS] [R/S] --> 66.422 degrees

atan(2.5) ::: 2.5 [CHS] [R/S] --> 68.199 degrees

The implementation of the sine function has 6-8 digits of accuracy.

The arctan function has at most an error around 0.001 degrees (that's 5 digits of accuracy).

IMPRESSIONS

I have been using this system during some days and I am happy, it is very natural. Now this classic Hp 12c feels like a scientific calculator with 24 steps to spare for little functions.

I hope someone finds this program useful.

IMPLEMENTATION

The constant PI/180 will be assigned to REG 0, in order to convert between radians and degrees.

REG 0 is neither a financial nor statistics register, so no problem.

Incidentaly, for calculating sin(x) when x is less than 1 degree, we can just multiply x by the constant in REG 0.

REG 4 will be used as temporary register by the three functions.

first of all:

3.141592654 [ENTER] 180 / [STO] [0]

program listing:

01 INTG

02 X=0?

03 GTO 40

04 0

05 LST X

06 X<=Y?

07 GTO 44

08 RCL 0 (SINCOS function)

09 3

10 /

11 *

12 STO 4

13 STO * 4

14 6

15 RCL 4

16 .

17 7

18 *

19 -

20 x

21 LST X

22 RCL 4

23 +

24 /

25 STO 4

26 STO * 4

27 3

28 RCL 4

29 4

30 *

31 -

32 *

33 STO 4 (COMPLEMENT function)

34 STO * 4

35 1

36 RCL 4

37 -

38 SQRT

39 GTO 00

40 LST X

41 X<=Y?

42 GTO 49

43 GTO 33

44 1/X (ARCTAN function)

45 CHS

46 9

47 0

48 X<>Y

49 STO 4

50 STO * 4

51 EEX

52 3

53 RCL 4

54 /

55 4

56 3

57 1

58 +

59 *

60 5

61 8

62 STO x 4

63 CLX

64 RCL 4

65 LST X

66 +

67 3

68 3

69 3

70 +

71 RCL 0

72 *

73 /

74 -

75 GTO 00

I recently bought a classic 1983 Hp 12c. I like it a lot, it's very cute.

But there are no trigonometric functions on this calculator, so I started to search information for programming those functions on this calculator.

The information I found in these forums is very good, mainly by Gerson Barbosa and Valentin Albillo, but it is geared towards the new incarnation of the Hp 12c that has more memory and is faster. I need a usable system for the Hp 12c that has only 99 steps of program memory.

I have these goals:

1. Of the 99 steps of program memory, 75% at most should be filled with the trigonometric functions, and the other 25% should remain free for programming the typical occasional functions.

2. Constants for computing the approximation polynomials should be hardcoded in those 75 steps,

so financial and statistical registers would be free for other things.

3. Only the [R/S] key should be used for executing all six trigonometric functions. The use of GOTO XX [R/S] for dispatching to different functions breaks the rythm (mentally and physically) of the human interface. This is what I don't like of the Hp 12c, having to remember all those goto addresses because there are no labels. So there should be dispatching code hardcoded in those 75 steps.

DESCRIPTION OF A SYSTEM

Once the user puts a number in the X register and presses [R/S], one of three functions gets called depending on the nature of the number x.

If 0 < x < 1

then the COMPLEMENT function gets executed, it returns the same number in the Y register, and SQRT(1-x*x) in the X register.

If x>=1

then the SINCOS function gets executed, it considers x as an angle measured in degrees, and returns SIN(x) in the Y register, and COS(x) in the X register.

If x<0

then the ARCTAN function gets executed, returns ARCTAN(-x) in the X register.

EXAMPLES

sin(25.3) ::: 25.3 [R/S] [X<>Y] --> 0.427358

cos(25.3) ::: 25.3 [R/S] --> 0.904083

tan(25.3) ::: 25.3 [R/S] [/] --> 0.472698

asin(0.3) ::: 0.3 [R/S] [/] [CHS] [R/S] --> 17.458 degrees

acos(0.4) ::: 0.4 [R/S] [X<>Y] [/] [CHS] [R/S] --> 66.422 degrees

atan(2.5) ::: 2.5 [CHS] [R/S] --> 68.199 degrees

The implementation of the sine function has 6-8 digits of accuracy.

The arctan function has at most an error around 0.001 degrees (that's 5 digits of accuracy).

IMPRESSIONS

I have been using this system during some days and I am happy, it is very natural. Now this classic Hp 12c feels like a scientific calculator with 24 steps to spare for little functions.

I hope someone finds this program useful.

IMPLEMENTATION

The constant PI/180 will be assigned to REG 0, in order to convert between radians and degrees.

REG 0 is neither a financial nor statistics register, so no problem.

Incidentaly, for calculating sin(x) when x is less than 1 degree, we can just multiply x by the constant in REG 0.

REG 4 will be used as temporary register by the three functions.

first of all:

3.141592654 [ENTER] 180 / [STO] [0]

program listing:

01 INTG

02 X=0?

03 GTO 40

04 0

05 LST X

06 X<=Y?

07 GTO 44

08 RCL 0 (SINCOS function)

09 3

10 /

11 *

12 STO 4

13 STO * 4

14 6

15 RCL 4

16 .

17 7

18 *

19 -

20 x

21 LST X

22 RCL 4

23 +

24 /

25 STO 4

26 STO * 4

27 3

28 RCL 4

29 4

30 *

31 -

32 *

33 STO 4 (COMPLEMENT function)

34 STO * 4

35 1

36 RCL 4

37 -

38 SQRT

39 GTO 00

40 LST X

41 X<=Y?

42 GTO 49

43 GTO 33

44 1/X (ARCTAN function)

45 CHS

46 9

47 0

48 X<>Y

49 STO 4

50 STO * 4

51 EEX

52 3

53 RCL 4

54 /

55 4

56 3

57 1

58 +

59 *

60 5

61 8

62 STO x 4

63 CLX

64 RCL 4

65 LST X

66 +

67 3

68 3

69 3

70 +

71 RCL 0

72 *

73 /

74 -

75 GTO 00