(Free42) tips & tricks: local flags
07-25-2020, 12:55 AM
Post: #21
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
(07-25-2020 12:08 AM)Paul Dale Wrote:  Sounds like it should be a function to me

Maybe, but I wasn't looking for advice how to implement it, but rather, information what that mode does on the real 41C. Could someone share a print-out sample?
07-25-2020, 01:54 AM
Post: #22
 rprosperi Senior Member Posts: 4,940 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
(07-24-2020 03:34 PM)Thomas Okken Wrote:  It looks like the real HP-42S does not have this mode. I checked with Emu42 and the HP82240B Printer Simulator.

It sounds like implementing this in Free42 would require changing most or all occurrences of

Code:
if flag 15 set and flag 55 set     PRX

to

Code:
if flag 15 set and flag 55 set     if flag 16 set         PRSTK     else         PRX

Is that what the real 41C with IL printer does? I have a 41CX but no printer so I can't check that either, and i41CX on my phone only emulates the 82143A where the printing mode is controlled by a hardware switch and flags 15 & 16 have no effect...

It would make sense for it to print the stack when STO ST operations are performed. Does the real thing do that?

That logic makes sense, except you should probably be using flag-21 instead of flag-55. Flag-55 is intended to indicate the physical presence of a printer (or module if IR). At each power-on the h/w sets SYSTEM flag-55 if it detects such presence and then it sets USER flag-21 to match the state of flag-55; thereafter the user can enable printer access by leaving flag-21 set, or disable printer access by clearing flag-21.

--Bob Prosperi
07-25-2020, 02:11 AM
Post: #23
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
(07-25-2020 01:54 AM)rprosperi Wrote:  That logic makes sense, except you should probably be using flag-21 instead of flag-55. Flag-55 is intended to indicate the physical presence of a printer (or module if IR). At each power-on the h/w sets SYSTEM flag-55 if it detects such presence and then it sets USER flag-21 to match the state of flag-55; thereafter the user can enable printer access by leaving flag-21 set, or disable printer access by clearing flag-21.

The code snippets I showed handle TRACE printing, and that only depends on the printer existing and TRACE mode being active. It is not disabled when flag 21 is clear.
07-25-2020, 01:13 PM
Post: #24
 rprosperi Senior Member Posts: 4,940 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
(07-25-2020 02:11 AM)Thomas Okken Wrote:
(07-25-2020 01:54 AM)rprosperi Wrote:  That logic makes sense, except you should probably be using flag-21 instead of flag-55. Flag-55 is intended to indicate the physical presence of a printer (or module if IR). At each power-on the h/w sets SYSTEM flag-55 if it detects such presence and then it sets USER flag-21 to match the state of flag-55; thereafter the user can enable printer access by leaving flag-21 set, or disable printer access by clearing flag-21.

The code snippets I showed handle TRACE printing, and that only depends on the printer existing and TRACE mode being active. It is not disabled when flag 21 is clear.

I understand what it was intending to do, I'm suggesting it should honor the flag-21 setting, as a real 41 would; why would you ignore the user's preference if she chose to disable the printer?

--Bob Prosperi
07-25-2020, 02:33 PM
Post: #25
 Werner Senior Member Posts: 641 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
Because that’s what the 42S does in this case
Werner
07-25-2020, 03:37 PM
Post: #26
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
Clearing flag 21 doesn't disable TRACE printing on the 41, either.

Could someone who has a working 82242 run a quick sample and capture its output with flags 15 & 16 set, on a real 82240 or using INPRT on a 48? Something like

Code:
01 LBL "TEST" 02 2 03 ENTER^ 04 3 05 * 06 STO ST Y 07 "ABC" 08 |-"DEF" 09 END

...just to give me an idea what gets printed and how the output is laid out.
07-25-2020, 06:22 PM
Post: #27
 Vincent Weber Member Posts: 205 Joined: May 2015
RE: (Free42) tips & tricks: local flags
(07-24-2020 09:39 AM)Werner Wrote:  BTW Free42 doesn't do a 'trace with stack print' when both flag 15 and 16 are set - I have no idea (and no means to find out) if a 42S does that or not. The flags doc mentions this is a 'HP-IL' printer behaviour, which of course doesn't apply to a 42S.
Werner
As far as I know, the "TRACE WITH A STACK" mode is not meant for the HP-IL printer, but for the video interface.
Could be useful for the free42 printer, though.
07-25-2020, 06:26 PM
Post: #28
 Gene Moderator Posts: 1,184 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
"Could be useful for the free42 printer, though."

Gene: And that's what I think would be very helpful here!
07-25-2020, 07:07 PM (This post was last modified: 07-25-2020 07:41 PM by rprosperi.)
Post: #29
 rprosperi Senior Member Posts: 4,940 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
You're right, it ignores flag-21, much to my surprise.

Sample output attached.

Though, if you're going to implement it, I'd still say it should honor flag-21 so the user has more control. I get that the 'why not?' answer of 'because the original doesn't' is true to the spirit of Free42, but it seems small improvements, when they don't break programs/code behavior, have been rightly made in the past and I'd say this is an example of when it should.

What is the downside of doing so?

Update: Added sample from a genuine 42S.

Attached File(s) Thumbnail(s)

--Bob Prosperi
07-25-2020, 08:25 PM
Post: #30
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
(07-25-2020 07:07 PM)rprosperi Wrote:  You're right, it ignores flag-21, much to my surprise.

Sample output attached.

Though, if you're going to implement it, I'd still say it should honor flag-21 so the user has more control. I get that the 'why not?' answer of 'because the original doesn't' is true to the spirit of Free42, but it seems small improvements, when they don't break programs/code behavior, have been rightly made in the past and I'd say this is an example of when it should.

What is the downside of doing so?

I think the idea is that if you don't want TRACE output, you can always use MAN or NORM mode, while TRACE mode should work even if flag 21 is clear. Some programs are designed to work with flag 21 set or clear, and you should be able to debug such programs using TRACE with either setting. Of course there is an assumption that programs will not change PRON/PROFF and MAN/NORM/TRACE modes by themselves.

(07-25-2020 06:22 PM)Vincent Weber Wrote:
(07-24-2020 09:39 AM)Werner Wrote:  BTW Free42 doesn't do a 'trace with stack print' when both flag 15 and 16 are set - I have no idea (and no means to find out) if a 42S does that or not. The flags doc mentions this is a 'HP-IL' printer behaviour, which of course doesn't apply to a 42S.
Werner
As far as I know, the "TRACE WITH A STACK" mode is not meant for the HP-IL printer, but for the video interface.
Could be useful for the free42 printer, though.

(07-25-2020 07:07 PM)rprosperi Wrote:  Update: Added sample from a genuine 42S.

Bob: Thanks!

I was under the impression the 'trace with stack print' mode was supported by the 82242, but apparently not. I would be interested to see what it looks like with the video interface, but I guess at the end of the day, it's up to me to decide how to implement that mode in Free42, since compatibility is not a concern and it's just an added convenience for user code debugging.
07-25-2020, 08:43 PM
Post: #31
 Vincent Weber Member Posts: 205 Joined: May 2015
RE: (Free42) tips & tricks: local flags
From HP key notes V6N2, may 1982:
"The new HP-IL Video Interface is all that is needed if you want just a convenient way to output data and programs in video. The HP-41 printer commands in this new module will allow all normal character output to occur in a very friendly manner. Flags 15 and 16 in the HP-41 will control the PRINT (output) mode to the video display. For example, when flag 15 is SET, it will make the video display act like a printer in TRACE mode; and when flag 16 is SET, it will make the video display act like a printer in NORMAL mode. And, when both flags are SET, they will put the video display into a new "TRACE WITH STACK OPTION" mode that will cause stack registers X, Y, Z, and T to be "printed" (displayed) after each operation. Now you'll be able to "see" how you left the stack and what is in it! (Very nice, yes?) Finally, with both flags CLEAR, the video display will be in MANUAL mode. "
07-25-2020, 09:10 PM
Post: #32
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
So just doing PRSTK instead of PRX whenever an instruction is executed that may change the X register should do the trick. With a couple of tweaks: suppress the blank line that normally comes before the stack output, and print the stack also when STO or STO arithmetic are performed on any of the stack registers.
07-25-2020, 09:22 PM (This post was last modified: 07-25-2020 09:22 PM by rprosperi.)
Post: #33
 rprosperi Senior Member Posts: 4,940 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
Thanks Thomas, the ability to debug with flag-21 set either way is a reasonable premise, but it seems a stretch...

[scroll-scroll-scroll...flip-flip...scroll-scroll] Minutes later..

Some relevant and interesting notes:

The 82160A HP-IL module manual states that the 'TRACE with stack' option is not available in the 82162A printer. I only recall seeing this on a ThinkJet, guess that's why. (HP probably concluded supporting this would kill the 82162A batteries pretty quickly)

The 82242A manual does not mention 'TRACE with stack' option at all, and it says clearly that 'TRACE mode' is selected when flag-15 is set, with flag-16 either set or cleared.

It also states: "When flag 21 is clear, execution of printing functions in a program is suppressed." It also notes that flag-21 does not affect print functions executed from the keyboard, only print functions contained in a program.

--Bob Prosperi
07-25-2020, 09:35 PM
Post: #34
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
(07-25-2020 09:22 PM)rprosperi Wrote:  Thanks Thomas, the ability to debug with flag-21 set either way is a reasonable premise, but it seems a stretch...

I guess it's not a tremendously strong argument, but given that there are three ways to control print-out already, messing with that functionality doesn't seem worth it to me.

(07-25-2020 09:22 PM)rprosperi Wrote:  [scroll-scroll-scroll...flip-flip...scroll-scroll] Minutes later..

Some relevant and interesting notes:

The 82160A HP-IL module manual states that the 'TRACE with stack' option is not available in the 82162A printer. I only recall seeing this on a ThinkJet, guess that's why. (HP probably concluded supporting this would kill the 82162A batteries pretty quickly)

Not to mention use reams of expensive thermal paper, and slow down program execution a lot! Trace-with-stack really seems more useful when it's printing to a scrollable window or a file.

(07-25-2020 09:22 PM)rprosperi Wrote:  The 82242A manual does not mention 'TRACE with stack' option at all, and it says clearly that 'TRACE mode' is selected when flag-15 is set, with flag-16 either set or cleared.

It also states: "When flag 21 is clear, execution of printing functions in a program is suppressed." It also notes that flag-21 does not affect print functions executed from the keyboard, only print functions contained in a program.

Yep, that's all consistent between the 41 with 82143A and 42S with 82240.
07-25-2020, 09:43 PM
Post: #35
 rprosperi Senior Member Posts: 4,940 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
I agree; as you described above is reasonable and is as consistent as possible, given that either way it's a bit of inventing something slightly different.

Of all the ways one might want to use the stack dump mode, I think the only practical option is if you can capture the output (like with ILPer) to analyze later, but that's 30+ years after the fact, so surely not what they had in mind.

--Bob Prosperi
07-27-2020, 06:16 PM (This post was last modified: 07-27-2020 09:51 PM by ijabbott.)
Post: #36
 ijabbott Senior Member Posts: 1,021 Joined: Jul 2015
RE: (Free42) tips & tricks: local flags
(07-25-2020 03:37 PM)Thomas Okken Wrote:  Clearing flag 21 doesn't disable TRACE printing on the 41, either.

Could someone who has a working 82242 run a quick sample and capture its output with flags 15 & 16 set, on a real 82240 or using INPRT on a 48? Something like

Code:
01 LBL "TEST" 02 2 03 ENTER^ 04 3 05 * 06 STO ST Y 07 "ABC" 08 |-"DEF" 09 END

...just to give me an idea what gets printed and how the output is laid out.

Will a capture from a real HP-42S to Christoph Giesselink's HP82240B simulator via Martin Hepperle's red-eye interface do? Because that's what I've just done:

Code:
              XEQ "TEST"               LBL "TEST"                        2                    ENTER                        3                        ×            6.0000    ***                 STO ST Y                    "ABC"                   ⊦"DEF"                    .END.

EDIT: updated, because it took a few attempts to get a clean capture. I kept getting bits missing and/or bits replaced with "{M=1}".

Attached File(s) Thumbnail(s)

— Ian Abbott
07-27-2020, 08:40 PM
Post: #37
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
Thank you for the print-out samples. I just took a first stab at a trace-with-stack implementation in Free42, and it prints this for my little sample program:

Code:
              XEQ "TEST"            01▸LBL "TEST"              02 2                     03 ENTER                 04 3                     05 ×        T=                     0 Z=                     0 Y=                     0 X=                     6              06 STO ST Y T=                     0 Z=                     0 Y=                     6 X=                     6              07 "ABC"                 08 ├"DEF"   ABCDEF              09 .END.

For comparison, it prints this in regular TRACE mode:

Code:
              XEQ "TEST"            01▸LBL "TEST"              02 2                     03 ENTER                 04 3                     05 ×                        6    ***              06 STO ST Y              07 "ABC"                 08 ├"DEF"   ABCDEF              09 .END.

It still needs some work. When printing only X, it isn't useful to print anything for number entry and ENTER, for example, but with trace-with-stack, it does make sense to print something there.
07-27-2020, 11:15 PM (This post was last modified: 07-28-2020 12:49 AM by Sylvain Cote.)
Post: #38
 Sylvain Cote Senior Member Posts: 1,700 Joined: Dec 2013
RE: (Free42) tips & tricks: local flags
AND program published in the latest HPCC Datafile
• HP-82143A Thermal Printer : TRACE mode set and used for program listing and execution tracing. => LISTING + EXECUTION
• HP-82162A Thermal Printer : TRACE mode set and used for program listing and execution tracing. => identical to the 82143A listing
• HP-82163A Video Interface : TRACE+STACK mode set and used for program listing and execution tracing. => LISTING 1 of 2 / LISTING 2 of 2 / EXECUTION VIDEO
Notes:
• HP-82143A Thermal Printer : trace mode with stack not available, Flag 15 & 16 not used, physical switch is used
• HP-82162A Thermal Printer : trace mode with stack not available, Flag 15 & 16 not used, physical switch is used
=> status byte / print mode values of 1,1 is used to report a carrier JAM and it is why Trace mode with Stack is not available at the switch.
• HP-82163A Video Interface : trace mode with stack available, Flag 15 & 16 set to 1
07-28-2020, 01:11 AM (This post was last modified: 07-29-2020 01:38 AM by Thomas Okken.)
Post: #39
 Thomas Okken Senior Member Posts: 1,300 Joined: Feb 2014
RE: (Free42) tips & tricks: local flags
It looks like Free42 already matches those behaviors, apart from some minor cosmetic differences, like suppressing the blank line before the stack print-out, printing line numbers for all executed program lines instead of only for LBL lines, and some alignment differences. I think I'll leave it the way it is in the development version for now.

Thank you Sylvain!
10-29-2020, 03:41 PM
Post: #40
 Albert Chan Senior Member Posts: 1,582 Joined: Jul 2018
RE: (Free42) tips & tricks: local flags
(07-24-2020 10:19 AM)Paul Dale Wrote:  A 64 bit binary float can safely hold 62 flags:
...
All 64 bits could be used at a pinch if no operations were ever done.

I recently learned that quiet/signal NaN bit may change even if no operations were done on it.
Just copying the double, say x = x, may flip the bit (turn NaN quiet)

So, maximum number of bits that can be used for flags is 63.
 « Next Oldest | Next Newest »

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