(10-19-2015 09:06 PM)TASP Wrote: (...) perhaps someone could enter the program on an HP97 and run it with a few examples using 'TRACE' mode.
Not exactly what you want but I quickly wrote a
convert(n_from, from_base, to_base) function that let's you run the innermost loop. Thus either
from_base or
to_base must be a power of 10.
Here are the examples I used:
convert(23, 10, 2)
Code:
Code | X | Y | Z | T | Register
LBL 1 | 23 | 8 | 0 | 0 | R0: 23
RCL 1 | 10 | 23 | 8 | 0 | R0: 23
X<>Y | 23 | 10 | 8 | 0 | R0: 23
RCL 2 | 2 | 23 | 10 | 8 | R0: 23
/ | 11 | 10 | 8 | 8 | R0: 23
INT | 11 | 10 | 8 | 8 | R0: 23
X=0 | 11 | 10 | 8 | 8 | R0: 23
RDN | 10 | 8 | 8 | 11 | R0: 23
* | 80 | 8 | 11 | 11 | R0: 23
RDN | 8 | 11 | 11 | 80 | R0: 23
* | 88 | 11 | 80 | 80 | R0: 23
STO+ 0 | 88 | 11 | 80 | 80 | R0: 111
RDN | 11 | 80 | 80 | 88 | R0: 111
GTO 1 | 11 | 80 | 80 | 88 | R0: 111
LBL 1 | 11 | 80 | 0 | 0 | R0: 111
RCL 1 | 10 | 11 | 80 | 0 | R0: 111
X<>Y | 11 | 10 | 80 | 0 | R0: 111
RCL 2 | 2 | 11 | 10 | 80 | R0: 111
/ | 5 | 10 | 80 | 80 | R0: 111
INT | 5 | 10 | 80 | 80 | R0: 111
X=0 | 5 | 10 | 80 | 80 | R0: 111
RDN | 10 | 80 | 80 | 5 | R0: 111
* | 800 | 80 | 5 | 5 | R0: 111
RDN | 80 | 5 | 5 | 800 | R0: 111
* | 400 | 5 | 800 | 800 | R0: 111
STO+ 0 | 400 | 5 | 800 | 800 | R0: 511
RDN | 5 | 800 | 800 | 400 | R0: 511
GTO 1 | 5 | 800 | 800 | 400 | R0: 511
LBL 1 | 5 | 800 | 0 | 0 | R0: 511
RCL 1 | 10 | 5 | 800 | 0 | R0: 511
X<>Y | 5 | 10 | 800 | 0 | R0: 511
RCL 2 | 2 | 5 | 10 | 800 | R0: 511
/ | 2 | 10 | 800 | 800 | R0: 511
INT | 2 | 10 | 800 | 800 | R0: 511
X=0 | 2 | 10 | 800 | 800 | R0: 511
RDN | 10 | 800 | 800 | 2 | R0: 511
* | 8000 | 800 | 2 | 2 | R0: 511
RDN | 800 | 2 | 2 | 8000 | R0: 511
* | 1600 | 2 | 8000 | 8000 | R0: 511
STO+ 0 | 1600 | 2 | 8000 | 8000 | R0: 2111
RDN | 2 | 8000 | 8000 | 1600 | R0: 2111
GTO 1 | 2 | 8000 | 8000 | 1600 | R0: 2111
LBL 1 | 2 | 8000 | 0 | 0 | R0: 2111
RCL 1 | 10 | 2 | 8000 | 0 | R0: 2111
X<>Y | 2 | 10 | 8000 | 0 | R0: 2111
RCL 2 | 2 | 2 | 10 | 8000 | R0: 2111
/ | 1 | 10 | 8000 | 8000 | R0: 2111
INT | 1 | 10 | 8000 | 8000 | R0: 2111
X=0 | 1 | 10 | 8000 | 8000 | R0: 2111
RDN | 10 | 8000 | 8000 | 1 | R0: 2111
* | 80000 | 8000 | 1 | 1 | R0: 2111
RDN | 8000 | 1 | 1 | 80000 | R0: 2111
* | 8000 | 1 | 80000 | 80000 | R0: 2111
STO+ 0 | 8000 | 1 | 80000 | 80000 | R0: 10111
RDN | 1 | 80000 | 80000 | 8000 | R0: 10111
GTO 1 | 1 | 80000 | 80000 | 8000 | R0: 10111
LBL 1 | 1 | 80000 | 0 | 0 | R0: 10111
RCL 1 | 10 | 1 | 80000 | 0 | R0: 10111
X<>Y | 1 | 10 | 80000 | 0 | R0: 10111
RCL 2 | 2 | 1 | 10 | 80000 | R0: 10111
/ | 0 | 10 | 80000 | 80000 | R0: 10111
INT | 0 | 10 | 80000 | 80000 | R0: 10111
X=0 | 0 | 10 | 80000 | 80000 | R0: 10111
GTO 2 | 0 | 10 | 80000 | 80000 | R0: 10111
LBL 2 | 0 | 10 | 80000 | 80000 | R0: 10111
RCL 0 | 10111 | 0 | 10 | 80000 | R0: 10111
convert(325, 8, 10)
Code:
Code | X | Y | Z | T | Register
LBL 1 | 325 | -2 | 0 | 0 | R0: 325
RCL 1 | 8 | 325 | -2 | 0 | R0: 325
X<>Y | 325 | 8 | -2 | 0 | R0: 325
RCL 2 | 10 | 325 | 8 | -2 | R0: 325
/ | 32 | 8 | -2 | -2 | R0: 325
INT | 32 | 8 | -2 | -2 | R0: 325
X=0 | 32 | 8 | -2 | -2 | R0: 325
RDN | 8 | -2 | -2 | 32 | R0: 325
* | -16 | -2 | 32 | 32 | R0: 325
RDN | -2 | 32 | 32 | -16 | R0: 325
* | -64 | 32 | -16 | -16 | R0: 325
STO+ 0 | -64 | 32 | -16 | -16 | R0: 261
RDN | 32 | -16 | -16 | -64 | R0: 261
GTO 1 | 32 | -16 | -16 | -64 | R0: 261
LBL 1 | 32 | -16 | 0 | 0 | R0: 261
RCL 1 | 8 | 32 | -16 | 0 | R0: 261
X<>Y | 32 | 8 | -16 | 0 | R0: 261
RCL 2 | 10 | 32 | 8 | -16 | R0: 261
/ | 3 | 8 | -16 | -16 | R0: 261
INT | 3 | 8 | -16 | -16 | R0: 261
X=0 | 3 | 8 | -16 | -16 | R0: 261
RDN | 8 | -16 | -16 | 3 | R0: 261
* | -128 | -16 | 3 | 3 | R0: 261
RDN | -16 | 3 | 3 | -128 | R0: 261
* | -48 | 3 | -128 | -128 | R0: 261
STO+ 0 | -48 | 3 | -128 | -128 | R0: 213
RDN | 3 | -128 | -128 | -48 | R0: 213
GTO 1 | 3 | -128 | -128 | -48 | R0: 213
LBL 1 | 3 | -128 | 0 | 0 | R0: 213
RCL 1 | 8 | 3 | -128 | 0 | R0: 213
X<>Y | 3 | 8 | -128 | 0 | R0: 213
RCL 2 | 10 | 3 | 8 | -128 | R0: 213
/ | 0 | 8 | -128 | -128 | R0: 213
INT | 0 | 8 | -128 | -128 | R0: 213
X=0 | 0 | 8 | -128 | -128 | R0: 213
GTO 2 | 0 | 8 | -128 | -128 | R0: 213
LBL 2 | 0 | 8 | -128 | -128 | R0: 213
RCL 0 | 213 | 0 | 8 | -128 | R0: 213
convert(213, 10, 3)
Code:
Code | X | Y | Z | T | Register
LBL 1 | 213 | 7 | 0 | 0 | R0: 213
RCL 1 | 10 | 213 | 7 | 0 | R0: 213
X<>Y | 213 | 10 | 7 | 0 | R0: 213
RCL 2 | 3 | 213 | 10 | 7 | R0: 213
/ | 71 | 10 | 7 | 7 | R0: 213
INT | 71 | 10 | 7 | 7 | R0: 213
X=0 | 71 | 10 | 7 | 7 | R0: 213
RDN | 10 | 7 | 7 | 71 | R0: 213
* | 70 | 7 | 71 | 71 | R0: 213
RDN | 7 | 71 | 71 | 70 | R0: 213
* | 497 | 71 | 70 | 70 | R0: 213
STO+ 0 | 497 | 71 | 70 | 70 | R0: 710
RDN | 71 | 70 | 70 | 497 | R0: 710
GTO 1 | 71 | 70 | 70 | 497 | R0: 710
LBL 1 | 71 | 70 | 0 | 0 | R0: 710
RCL 1 | 10 | 71 | 70 | 0 | R0: 710
X<>Y | 71 | 10 | 70 | 0 | R0: 710
RCL 2 | 3 | 71 | 10 | 70 | R0: 710
/ | 23 | 10 | 70 | 70 | R0: 710
INT | 23 | 10 | 70 | 70 | R0: 710
X=0 | 23 | 10 | 70 | 70 | R0: 710
RDN | 10 | 70 | 70 | 23 | R0: 710
* | 700 | 70 | 23 | 23 | R0: 710
RDN | 70 | 23 | 23 | 700 | R0: 710
* | 1610 | 23 | 700 | 700 | R0: 710
STO+ 0 | 1610 | 23 | 700 | 700 | R0: 2320
RDN | 23 | 700 | 700 | 1610 | R0: 2320
GTO 1 | 23 | 700 | 700 | 1610 | R0: 2320
LBL 1 | 23 | 700 | 0 | 0 | R0: 2320
RCL 1 | 10 | 23 | 700 | 0 | R0: 2320
X<>Y | 23 | 10 | 700 | 0 | R0: 2320
RCL 2 | 3 | 23 | 10 | 700 | R0: 2320
/ | 7 | 10 | 700 | 700 | R0: 2320
INT | 7 | 10 | 700 | 700 | R0: 2320
X=0 | 7 | 10 | 700 | 700 | R0: 2320
RDN | 10 | 700 | 700 | 7 | R0: 2320
* | 7000 | 700 | 7 | 7 | R0: 2320
RDN | 700 | 7 | 7 | 7000 | R0: 2320
* | 4900 | 7 | 7000 | 7000 | R0: 2320
STO+ 0 | 4900 | 7 | 7000 | 7000 | R0: 7220
RDN | 7 | 7000 | 7000 | 4900 | R0: 7220
GTO 1 | 7 | 7000 | 7000 | 4900 | R0: 7220
LBL 1 | 7 | 7000 | 0 | 0 | R0: 7220
RCL 1 | 10 | 7 | 7000 | 0 | R0: 7220
X<>Y | 7 | 10 | 7000 | 0 | R0: 7220
RCL 2 | 3 | 7 | 10 | 7000 | R0: 7220
/ | 2 | 10 | 7000 | 7000 | R0: 7220
INT | 2 | 10 | 7000 | 7000 | R0: 7220
X=0 | 2 | 10 | 7000 | 7000 | R0: 7220
RDN | 10 | 7000 | 7000 | 2 | R0: 7220
* | 70000 | 7000 | 2 | 2 | R0: 7220
RDN | 7000 | 2 | 2 | 70000 | R0: 7220
* | 14000 | 2 | 70000 | 70000 | R0: 7220
STO+ 0 | 14000 | 2 | 70000 | 70000 | R0: 21220
RDN | 2 | 70000 | 70000 | 14000 | R0: 21220
GTO 1 | 2 | 70000 | 70000 | 14000 | R0: 21220
LBL 1 | 2 | 70000 | 0 | 0 | R0: 21220
RCL 1 | 10 | 2 | 70000 | 0 | R0: 21220
X<>Y | 2 | 10 | 70000 | 0 | R0: 21220
RCL 2 | 3 | 2 | 10 | 70000 | R0: 21220
/ | 0 | 10 | 70000 | 70000 | R0: 21220
INT | 0 | 10 | 70000 | 70000 | R0: 21220
X=0 | 0 | 10 | 70000 | 70000 | R0: 21220
GTO 2 | 0 | 10 | 70000 | 70000 | R0: 21220
LBL 2 | 0 | 10 | 70000 | 70000 | R0: 21220
RCL 0 | 21220 | 0 | 10 | 70000 | R0: 21220
You can use it with your own examples if you want. Just follow the link above and click
run.
Enter the
convert function with the desired parameters into the black box and hit the
Enter key.
Cheers
Thomas
PS: I cheated a little with this line:
As the next step is
INT I didn't bother with floating point numbers and just used integer division. On a HP-42S both steps could be replaced by
BASE/.