Post Reply 
(71B) RPN (v2)
06-13-2024, 05:17 AM
Post: #1
(71B) RPN (v2)
Memory Used:

U = temporary register
X = x stack
Y = y stack
Z = z stack
T = t stack
L = last x register
M = memory register


Keys

Stack Operation

[ END LINE ]: Enters a number. The number is placed on the X stack while everything else is pushed up one level. Note: The key string code for END LINE is #38.

[ ↑ ]: Swap: swaps the contents of X and Y stacks. The key string code for ↑ is #50.

[ ↓ ]: Roll Down: brings the stack contents down one level (T to Z, Z to Y, Y to X, X wraps around to T). The key string code for ↓ is #51.

[ f ] [ ↓ ] (-LINE): Drop: Drops the stack down, Y replaces X, Z goes to Y, and T is copied to Z. This is effectively erasing the contents of stack X, and is similar to the HP 48’s DROP command. The key string code for -LINE is #107.

[ f] [ ) ] (COPY): Duplicate: Duplicates the contents of the X stack to the Y stack, after Y transfer to Z and Z transfers to T. This command is similar to the HP 48’s DUP command. The key string code for COPY is f) (small F, right parenthesis).

[ P ]: Pi (π): Enters the numeric constant π to the X stack and pushes everything else up. The contents of the T stack are lost.

[ M ]: Stores the contents of X into the memory register.

[ S ]: Adds the contents of X to the memory register (M+).

[ g ] [ M ] (m): Recalls the contents of the memory register to the X stack and pushes everything else up. The contents of the T stack are lost.

[ f ] [ END LINE ] (RES): Recalls the contents of the last X register to the X stack and pushes everything else up. The contents of the T stack are lost. The key string code for RES is #94.

[ N ]: Negate: changes the sign of the X stack. This is the change sign key.


Arithmetic and Two-Argument Operations

All these operations update the Last X register. The contents of the Z register get copied to the Y register, then the contents of T gets copied to Z.

[ + ]: Addition: Y + X.

[ - ]: Subtraction. Y – X.

[ * ]: Multiplication. Y * X

[ / ]: Division: Y / X

[ g ] [ / ] (^) : Power: Y^X

[ g ] [ 5 ] (%): Modulus. mod(Y,X)


One-Argument Operations

All these operations update the Last X register. No other stack levels are affected.

[ f ] [ / ] (SQR): Principal (positive) Square Root of X. The key string code for SQR is f/ (small f, division).

[ U ]: Square of X. (X^2 = X * X).

[ I ]: Reciprocal of X. (1/X)

[ F ]: Fractional part of X.

[ g ] [ F ] (f): Integer part of X.

[ f ] [ - ] (LOG): Natural logarithm of X. ln(X) The key string code for LOG is f- (small f, subtraction).

[ f ] [ * ] (EXP): Exponential of X. e^X (e is about 2.71828...) The key string code for EXP is f* (small f, multiplication).

[ f ] [ 4 ] (SIN): Sine of X.

[ f ] [ 5 ] (COS): Cosine of X

[ f ] [ 6 ] (TAN): Tangent of X

[ f ] [ 1 ] (ASIN): Arc-sine of X

[ f ] [ 2 ] (ACOS): Arc-cosine of X

[ f ] [ 3 ] (ATAN): Arc-tangent of X

[ D ]: Change to Degrees mode

[ g ] [ D ] (d): Convert X from radians to degrees

[ R ]: Change to Radians mode

[ g ] [ R ] (r): Convert X from degrees to radians

[ g ] [ 3 ] (#): Generate a random number between 0 and 1.

[ f ] [ = ] (FACT): Factorial of X. X must be a positive integer.

[ f ] [ , ] ( > ): Convert rectangular to polar. X: x-coordinate to radius, Y: y-coordinate to angle

[ f ] [ . ] ( < ): Convert polar to rectangular. X: radius to x-coordinate, Y: angle to y-coordinate


HP 71B Basic Program Code: RPNT
Memory: 1253 bytes


Code:
10 DESTROY U,X,Y,Z,T,M,L,K$
15 DIM U,X,Y,Z,T,M,L,K$
20 DISP “RPN BASIC” @ WAIT 1
22 DISP “EXIT = E” @ WAIT 1
25 DELAY 0,0
30 DISP “X: “; X
35 K$ = KEY$
40 IF K$=”E” THEN DISP “THANK YOU.” @ STOP

60 IF K$=”#38” THEN 300     
62 IF K$=”#50” THEN U=X @ X=Y @ Y=U 
64 IF K$=”#51” THEN U=X @ X=Y @ Y=Z @ Z=T @ T=U 
66 IF K$=”#107” THEN X=Y @ Y=Z @ Z=T 
68 IF K$=”f)” THEN T=Z @ Z=Y @ Y=X 
70 IF K$=”P” THEN U=PI @ GOTO 304
72 IF K$=”M” THEN M=X 
73 IF K$=”S” THEN M=X+M 
74 IF K$=”m” THEN U=M @  GOTO 304
76 IF K$=”#94” THEN U=L @ GOTO 304
78 IF K$=”N” THEN X=-X 

80 IF K$=”+” THEN U=Y+X @ GOTO 310
82 IF K$=”-” THEN U=Y-X @ GOTO 310
84 IF K$=”*” THEN U=Y*X @ GOTO 310
86 IF K$=”/” THEN U=Y/X @ GOTO 310
88 IF K$=”^” THEN U=Y^X @ GOTO 310
90 IF K$=”%” THEN U=MOD(Y,X) @ GOTO 310

100 IF K$=”f/” THEN L=X @ X=SQR(X) 
102 IF K$=”U” THEN L=X @ X=X^2 
104 IF K$=”A” THEN L=X @ X=ABS(X) 
106 IF K$=”I” THEN L=X @ X=1/X 
108 IF K$=”F” THEN L=X @ X=FP(X) 
110 IF K$=”f” THEN L=X @ X=IP(X) 
112 IF K$=”f-” THEN L=X @ X=LOG(X) 
114 IF K$=”f*” THEN L=X @ X=EXP(X) 
116 IF K$=”f4” THEN L=X @ X=SIN(X) 
118 IF K$=”f5” THEN L=X @ X=COS(X) 
120 IF K$=”f6” THEN L=X @ X=TAN(X) 
122 IF K$=”f1” THEN L=X @ X=ASIN(X) 
124 IF K$=”f2” THEN L=X @ X=ACOS(X) 
126 IF K$=”f3” THEN L=X @ X=ATAN(X) 
128 IF K$=”D” THEN DEGREES 
130 IF K$=”R” THEN RADIANS 
132 IF K$=”d” THEN L=X @ X=DEG(X) 
134 IF K$=”r” THEN L=X @ X=RAD(X) 
136 IF K$=”#” THEN L=X @ U=RND @ GOTO 304
138 IF K$=”f=” THEN L=X @ X=FACT(X)
140 IF K$=”>” THEN L=X @ X=SQR(L^2+Y^2) @ Y=ANGLE(L,Y)
142 IF K$=”<” THEN L=X @ X=L*COS(Y) @ Y=L*SIN(Y)
199 GOTO 30

300 INPUT “NUMBER? “; U
302 ! STACK
304 T=Z @ Z=Y @ Y=X @ X=U
306 GOTO 30

310 ! 2 ARG
312 L=X @ X=U @ Y=Z @ Z=T 
314 GOTO 30


Example Calculations

1. Find the percent change from 8000 to 12000. Formula: (12000 – 8000) / 8000 * 100

Keystrokes:
[END LINE] 12000 [END LINE]
[END LINE] 8000 [END LINE]
[ - ]
[ f ] [END LINE] (RES) <LASTx>
[ / ]
[END LINE] 100 [END LINE]
[ * ]

Result: 50 (50%)


2. e^(2*π – 1)

Keystrokes:
[END LINE] 2 [END LINE]
[ P ] <enter π to the stack>
[ * ]
[END LINE] 1 [END LINE]
[ - ]
[ f ] [ * ] (EXP) <exp(x) =e^x>

Result: 196.996371

3. 1/(1/9 + ln 11 + 8^2)

Keystrokes:
[END LINE] 9 [END LINE]
[ I ] <1/x>
[END LINE] 11 [END LINE]
[ f ] [ - ] (LOG) <ln(x)>
[ + ]
[END LINE] 8 [END LINE]
[ U ] <x^2>
[ + ]
[ I ]

Result: 1.50355576541E-2

4. Use the memory register to calculate: 3 * 18 + 8 * 17

Keystrokes:
[END LINE] 3 [END LINE]
[END LINE] 18 [END LINE]
[ * ]
[ M ] <store into memory>
[END LINE] 8 [END LINE]
[END LINE] 17 [END LINE]
[ * ]
[ S ] <add to memory>
[ g ] [ M ] (m) <recall memory>

Result: 190

5. Find the arc-sin of 0.5 in degrees and radians

Keystrokes:
[ D ] <set degrees mode>
[END LINE] 0.5 [END LINE]
[ f ] [ ) ] (COPY) < copies 0.5 to Y >
[ f ] [ 1 ] (ASIN) < Result: 30 degrees >
[ ↑ ] < swap >
[ R ] < set radians mode, RAD indicator is on >
[ f ] [ 1 ] (ASIN) < Result: 0.523598775598 radians >


6. Calculate | 99 – 164 * 1.03^3 |

Keystrokes:
[END LINE] 99 [END LINE]
[END LINE] 164 [END LINE]
[END LINE] 1.03 [END LINE]
[END LINE] 3 [END LINE]
[ g ] [ / ] (^)
[ * ]
[ - ]
[ A ] < absolute value >

Result: 80.207228

7. Convert Rectangular to Polar with X = 4, Y = 5. Calculate the angle in degrees mode.

Keystrokes:
[ D ] <set degrees mode>
[END LINE] 5 [END LINE] <enter y first>
[END LINE] 4 [END LINE] <enter x next>
[ g ] [ , ] ( > ) < rectangular to polar>

Display: 6.40312423743 (radius)
[ ↑ ] <swap>
Display: 51.3401917459 (angle)

8. Convert Polar to Rectangular with R = 11, θ = 60°.

Keystrokes:
[ D ] <set degrees mode>
[END LINE] 60 [END LINE] <enter θ first>
[END LINE] 11 [END LINE] <enter r next>
[ g ] [ . ] ( < ) <polar to rectangular>

Display: 5.5 (x)
[ ↑ ]
Display: 9.52627944162
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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