Free42 extended "SHOW" fun


I recently picked up a copy of Free42 and it made me dig out the real thing to play with again. I'd forgotten many of the joys of using it, as well as the painful aspects, but they're all fresh in my mind again now. :)

At any rate, this program evolved over time, as they all do, and I guess it might be useful in some way to some of you, so I offer it for your consideration.

There might be enough comments within the listing. If not, ask.
I normally wouldn't use "@" for comments, but I seem to recall that was the convention for this sort of stuff.

Also, I don't presently have access to a web server to put a 39KB zip file on, so cannot include the .raw file and several formatted versions of the text listing. Sorry. I'll see what I can do if there's any interest.

Here it is:

00 { 388-Byte (Free42) Prgm }	@@ pretty much pointless on native hardware @@
01>LBL "FWIW" @"For What It's Worth"; "show" all digits of stack X value
02 GTO 01
03>LBL 00 @two options placed early for ease of manipulation:
04 3 @<- maximum quantity of digits pre-radix / min. "E" multiplier
05 STO ".M." @@ "1" = "SCI"; "3" = "ENG"; but others seem to work as well...
06 3 @<- digits "grouping" size post-radix; practical range begins
07 STO ".G." @@ at "3" and ends at "24" (see declaration of ".J." below)
08 RTN
09>LBL 01
10 REAL? @we'll be using "LOG" which won't work well otherwise
11 GTO 02
12 GTO 11 @so abort; it's "otherwise"
13>LBL 02
14 X=0? @if nothing's in the register this whole thing's (even more?)
15 GTO 11 @@ pointless, so just skip to the end
16 STO ".X." @place copies of the stack aside for later restoration:
17 Rv @ @ excepting the ALPHA register, this program leaves the
18 STO ".Y." @ @ machine completely in it's same prior state when done
19 Rv @ @ unless named variables herein had pre-existed (see list
20 STO ".Z." @ @ of "CLV"s at the end); no user flags or REGs get molested
21 Rv
22 STO ".T."
24 STO ".L."
25 CLA
26 XEQ 00
27 STO ".I."
28 24 @<- this variable is only necessary in Free42bin, where a
29 STO ".J." @@ smaller value would really be more appropriate anyway since
30 RCL ".X." @@ "noise" starts earlier, and keeps rising like so much radon
31 SIGN @@ from the cellar in that version
32 STO ".S." @<- keep track of the sign for display purposes
34 ABS @LOG likes positive values for "real" results
36 LOG @this section would be as easy to step through and watch as
37 ENTER @to read a description of it; at least easier than writing it...
38 X>=0?
39 GTO 03
40 FP
41 X=0?
42 GTO 03
43 Rv
44 IP
45 1
46 -
48>LBL 03
49 Rv
50 IP
51 STO ".E."
52 RCL ".M."
53 MOD
54 STO- ".E."
55 Rv
56 RCL ".E."
57 10^X
58 X=0? @<- depending on ".M." (if >1) plus proximity to limits of
59 GTO 09 @@ "-E" values (where things can get "dicey" anyway for this in
60 ÷ @@ Free42bin), trouble can ensue here; this allows restoration
61 RCL× ".S." @@ of state in that unfortunate event, accompanied by a cryptic
62 AIP @@ statement at (failed) program exit (see below)
63 RCL× ".S."
64 FS? 28 @here we follow current radix display convention
65 |-"."
66 FC? 28
67 |-","
68 FP
69>LBL 04 @start appending post-radix digits
70 10
71 ×
72 AIP
73 FP
74 DSE ".J." @<- in Free42dec this isn't even necessary but in *bin it is;
75 X=0? @<- *dec's digits run out and break loop all on their own
76 GTO 07
77 DSE ".I." @restart in-group loop or add (linefeed/)separator to ALPHA
78 GTO 04
79 RCL ".G."
80 STO ".I." @re-use variable here to count back "group-size" digits from
81 Rv @@ end of first ALPHA line-width, to ensure entire
82 ALENG @@ un-"wrap-broke" groupings
83 22
84 X<=Y?
85 GTO 06
86 1
87 -
88>LBL 05 @add a linefeed within any appropriate group separator
89 X=Y?
90 |-"\LF"
92 DSE ".I."
93 GTO 05
94 RCL ".G."
95 STO ".I." @re-reset counter for adding another "group" of digits to ALPHA
96 Rv
97>LBL 06
98 |-" " @at least this'll happen whenever we get into this loop
100 GTO 04 @back for (possibly) more digits above...
101>LBL 07 @no more digits to add at this point
103 22
104 X<=Y? @add a linefeed if needed to prevent exponent component from
105 GTO 08 @@ getting "wrap-broke"
106 10 @@ as a result of "rudimentaryness" it'll always appear on the
107 POSA @@ second line of the display, even with a very short mantissa
108 X<0?
109 |-"\LF"
110>LBL 08 @and here it comes...
111 |-" E" @this is the "exponent" (little big) "E"
112 RCL ".E."
113 AIP
114 GTO 10
115>LBL 09 @this is the cryptic "we'd 'divode' by zero" message, if needed,
116 "Went out of" @ it can (probably?) be avoided by using a "1" for ".M."
117 |-" range! :("
118>LBL 10
119 AVIEW @show result
120 CLA @wipe the slate
121 RCL ".L." @restore all program-changed state
122 STO ST L
123 RCL ".T."
124 RCL ".Z."
125 RCL ".Y."
126 RCL ".X."
127 CLV ".M." @the unsorted list of variables created(?)/destroyed ensues
128 CLV ".G."
129 CLV ".I."
130 CLV ".J."
131 CLV ".S."
132 CLV ".E."
133 CLV ".L."
134 CLV ".T."
135 CLV ".Z."
136 CLV ".Y."
137 CLV ".X."
138>LBL 11
139 END
@I believe I've culled all code which would never get called...
@ © GMS 21 Feb 2011, for what it's worth :)

EDIT: Here's the FWIW.raw file uuencoded (base64):

begin-base64 644 FWIW.raw

Edited: 24 Feb 2011, 12:46 a.m.



What does it do?



Perhaps familiarity with it has clouded my judgement. I'd guessed there was enough information in the thread title, what little I'd posted about it, and the notes in the code listing itself.

The Free42 program comes in two versions (.bin and .dec) using different math libraries. One is faster, one is more accurate. I'm pretty sure all that's in the program's documentation. In either case, there are more digits in use than just the (up to) 12 shown in the display.

I was curious about those digits and wished to compare them to results from other "calculator" programs I have at my disposal.

What I put together will (should) non-destructively (except for the ALPHA register) "SHOW" the full numerical value in the X register. It does so according to a couple formatting variables you can set to taste very early in the program, as indicated by the notes in my listing above.


What editor did you write this in so you could save it off in a .raw format for importing into Free42? (Sorry if this sounds like a dumb question.)


Never mind. I just received this link of a translator from Thomas Okken that will do the trick:


I just tried that, and it didn't work too well for me, even after editing out my comments &c.

Go to and paste this uuencoded version into the textarea, then click "Decode". It'll decode into the binary format and prompt you to save the file. It didn't know what to do with my previous "base64" version, but the following works perfectly there. Cut/paste everything below from "begin" to "end", inclusive, into that web page's textarea.

begin 644 FWIW.raw

Otherwise, you could just take the time to key in the program, hahaha!

(Note: I just performed the operation outlined above using the link and text from the preview version of this post to obtain a bit-for-bit version of FWIW.raw)


So...I'll repeat Dwight's question: What does it do? Why should someone wade through comments in a long listing to determine a program's purpose?


I only had to read the comment on the first program line... {:-)


How about the first two lines of the listing?

00 { 388-Byte (Free42) Prgm }	@@ pretty much pointless on native hardware @@
01>LBL "FWIW" @"For What It's Worth"; "show" all digits of stack X value

Or my post above in response to his question?


Hi Glen, will convert your listing as shown in your initial post; you just have to delete all the non-program lines (including line 00; I think may not like how you edited that line but I admit I haven't checked that), and get rid of all the comments (for vi users, :%s/^\([^@]*\)@.*/\1/ does the job; everyone else, do whatever you have to do to get rid of any '@' signs and whatever follows them on the same line).

Having cleaned up the listing like that, converts it to a *.raw file that is identical to your uuencoded version, except for one byte, namely, offset 0x10a, which is a regular 'E' in the listing and an HP-42S small-caps exponent 'E' in the uuencoded raw file -- a cosmetic issue only since this is in a text string.

I like this program and I'll add it to my collection. :-) Being able to see the full precision is useful sometimes, and it's something that the Free42 implementation of SHOW doesn't do, because it tries to mimic the HP-42S by displaying no more than 12 digits.

For Free42 Binary, you could improve the code a bit by having it display 16 digits instead of 25 -- given the 53-bit mantissa of IEEE-754, those last 9 digits are basically just noise.

- Thomas


Hi Thomas.

Pleased to meet you and thank you very much for Free42! (I swear that with the realistic "skin" I can almost feel the keypad button move with just the right sensation under my finger when I click the mouse)

I'd tried the txt2raw script a couple times before posting earlier about it. The first time I ended up with only the "E" difference but I recall that when I reverted

 >LBL 08      @and here it comes...
- |-" "
- 24
+ |-" E" @this is the "exponent" (little big) "E"
RCL ".E."
then my luck wasn't so good. Probably I'd just mis-compared something the second time.

I had to add the ".J." stuff to use this with free42bin. Note my notes at lines 28ff and 74f.

Don't forget to play around with the two values at lines 4 and 6. I put their declarations up as near the top as I could so they can be altered with little fuss. It's quite easy to then just up-arrow a few times before exiting the program-entry mode and be ready for an immediate R/S.

I'd placed tabs before the @s (they should still be there even after a cut-paste from this thread) so what I'd do in vi is

or probably just
sed 's,\t.*,,; 1d' | ./ -

I threw the (Free42) into the program header line hoping to help prevent some poor soul going to all the trouble of entering the program into their native hardware. However, if one has the notion to do so, throw an AVIEW in after line 72 (AIP) which will make it funner to watch while waiting, and waiting.

Feel free to freely include this with your Free42 website stuff if you have half a notion.


Even though I'd considered it a finished product when originally posted here, I went ahead and made a few changes:

- All three "user options" are now available near the head of the program for ease of manipulation and are each preceded by a line of reference text.

- The routine which determines whether a linefeed should be inserted was changed from a loop scheme to (up to) three simple X--Y tests.

- A couple of variables were replaced with judicious stack use.

Here are some performance numbers obtained by looping 10 iterations "showing" PI on native hardware, timed manually using X48:

as originally posted = 50.95 seconds
(running the program singly the "busy" annunciator flashes a very brief 6th time)

with un-looped "line-feeder" = 44.08 seconds
(running singly the "busy" annunciator flashes a 5th time seemingly about half its normal duration)

fully(?) optimized (current version) = 37.47 seconds
(running singly the "busy" annunciator flashes a 4th time for what "feels" like an almost-full duty cycle)

There is a 13kB zip file containing the .raw file, a .gif image of the program listing "printout", and some text files at



Hi Glen,

Thanks for your contribution, I found it's very useful.



I get it. I use the real 42S most of the time. What you are saying is that the program will show the extra digits of precision that the Free42 maintains internally.


Hi Lyuka,

I found it's very useful.

So did I. Glen's program is a keeper!



8.999 999 999 999 999
999 931 316 E0

Instead of FWIW above, previously I had done

9 - E 24 * E 5 +

and gotten

(Free42 Decimal 1.4.62)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Fun graphs on HP Prime Mic 9 2,853 09-15-2013, 08:30 AM
Last Post: Eddie W. Shore
  ILPer with "auto-extended addressing" Christoph Giesselink 0 978 07-23-2013, 03:28 PM
Last Post: Christoph Giesselink
  Fun things found by running strings on the 39gII emulator bhtooefr 11 3,759 05-16-2013, 12:40 AM
Last Post: Mic
  Repaired HP-97 card reader doesn't show any signs of life jbssm 6 2,664 02-17-2013, 03:15 AM
Last Post: Alberto Fenini
  The latest version of Free42 is now a OS X Universal application..... zeno333 1 1,009 10-21-2012, 11:12 PM
Last Post: Matt Agajanian
  I need the last OS X "Universal" version of Free42..... zeno333 0 864 10-13-2012, 04:45 PM
Last Post: zeno333
  Fun with the HP-35 Gerson W. Barbosa 11 3,412 08-02-2012, 10:58 AM
Last Post: Gerson W. Barbosa
  First post here: something fun... Jeff Dinkins 4 1,587 04-22-2012, 02:42 PM
Last Post: Jeroen Van Nieuwenhove
  [OT] Free42 on the BlackBerry PlayBook Les Wright 1 1,064 02-25-2012, 10:56 AM
Last Post: Thomas Okken
  A show review of the SmartCalc 300s... Jose Gonzalez Divasson 3 1,493 02-22-2012, 05:10 PM
Last Post: Chris Smith

Forum Jump: