HP Forums

Full Version: DM42 and labels
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I recently added a DM42 with the latest free42 firmware to my collection. I noticed that some programs with labels inside don't behave like expected. For example:

LBL "AAA"
XEQ 00
XEQ 10
RTN
LBL 00
"00"
AVIEW
RTN
LBL 10
"10"
AVIEW
RTN

This program when executed will display "10" first, then "10" again, and a third time (!) "00" and then ends. I was expecting to display "00" and then "10". The same behavior occurs with numeric local labels or global labels. I'm new to DM42 (HP42s) programming but I have experience with HP35s which has a similar language. Am I missing something?

When I run it with SST (step by step) it behaves as expected though.
(05-19-2020 04:26 PM)mchris Wrote: [ -> ]I recently added a DM42 with the latest free42 firmware to my collection. I noticed that some programs with labels inside don't behave like expected. For example:

LBL "AAA"
XEQ 00
XEQ 10
RTN
LBL 00
"00"
AVIEW
RTN
LBL 10
"10"
AVIEW
RTN

This program when executed will display "10" first, then "10" again, and a third time (!) "00" and then ends. I was expecting to display "00" and then "10". The same behavior occurs with numeric local labels or global labels. I'm new to DM42 (HP42s) programming but I have experience with HP35s which has a similar language. Am I missing something?

When I run it with SST (step by step) it behaves as expected though.

I see:
10
00
10

in Free42, Emu42 and DM42
(05-19-2020 04:26 PM)mchris Wrote: [ -> ]I recently added a DM42 with the latest free42 firmware to my collection. I noticed that some programs with labels inside don't behave like expected. For example:

LBL "AAA"
XEQ 00
XEQ 10
RTN
LBL 00
"00"
AVIEW
RTN
LBL 10
"10"
AVIEW
RTN

This program when executed will display "10" first, then "10" again, and a third time (!) "00" and then ends. I was expecting to display "00" and then "10". The same behavior occurs with numeric local labels or global labels. I'm new to DM42 (HP42s) programming but I have experience with HP35s which has a similar language. Am I missing something?

When I run it with SST (step by step) it behaves as expected though.

Confirmed on both DM42 and Free42 (v2.5.28 windows), and also on an HP-42S (ROM A).

Note this does run as expected on the DM41X.

I expected the same as you, so I'll pause here for Thomas to comment. There is clearly some nuanced behavior in the 42S as it seems unlikely this is a bug that has gone unnoticed for so long.
(05-19-2020 05:30 PM)rprosperi Wrote: [ -> ]I expected the same as you, so I'll pause here for Thomas to comment. There is clearly some nuanced behavior in the 42S as it seems unlikely this is a bug that has gone unnoticed for so long.

... considering that I noticed it the 2nd day after purchasing the DM42!
Further testing...
The problem occurs only when an AVIEW function exists inside the subroutine. It somehow destroys the return stack or something like that.
(05-19-2020 04:26 PM)mchris Wrote: [ -> ]I recently added a DM42 with the latest free42 firmware to my collection. I noticed that some programs with labels inside don't behave like expected. For example:

LBL "AAA"
XEQ 00
XEQ 10
RTN
LBL 00
"00"
AVIEW
RTN
LBL 10
"10"
AVIEW
RTN

This program when executed will display "10" first, then "10" again, and a third time (!) "00" and then ends. I was expecting to display "00" and then "10". The same behavior occurs with numeric local labels or global labels. I'm new to DM42 (HP42s) programming but I have experience with HP35s which has a similar language. Am I missing something?

When I run it with SST (step by step) it behaves as expected though.

With Flag 21 set, I see 00 followed by 10 then the program ends, just as expected.

I use

Code:
DMCP 3.18 
DM42 3.15 
Free42 2.5.16
Intel Math Lib v2.0u1
...and adding a STOP after the AVIEW solves the problem!
(05-19-2020 04:26 PM)mchris Wrote: [ -> ]I recently added a DM42 with the latest free42 firmware to my collection. I noticed that some programs with labels inside don't behave like expected. For example:

LBL "AAA"
XEQ 00
XEQ 10
RTN
LBL 00
"00"
AVIEW
RTN
LBL 10
"10"
AVIEW
RTN

This program when executed will display "10" first, then "10" again, and a third time (!) "00" and then ends. I was expecting to display "00" and then "10". The same behavior occurs with numeric local labels or global labels. I'm new to DM42 (HP42s) programming but I have experience with HP35s which has a similar language. Am I missing something?

When I run it with SST (step by step) it behaves as expected though.

(05-19-2020 06:01 PM)mchris Wrote: [ -> ]...and adding a STOP after the AVIEW solves the problem!

... of course you didn't tell us all :-)
You pressed R/S 3 times, right?

No bug...

J-F
I have modified your program, I put a PSE after each AVIEW because the program ran too fast and I was only seeing the last aview on a real HP-42S (ROM: C7 SN: 3204S03610)
As I was expecting, I am seeing: "00" then "10" after each XEQ "AAA"
Code:
LBL "AAA"
XEQ 00
XEQ 10
RTN
LBL 00
"00"
AVIEW
PSE
RTN
LBL 10
"10"
AVIEW
PSE
RTN
(05-19-2020 05:57 PM)toml_12953 Wrote: [ -> ]With Flag 21 set, I see 00 followed by 10 then the program ends, just as expected.

Thanks Tom, that was quick detective work! What on earth made you think of trying Flag-21 - just using AVIEW commands?
I just ran the program in Free42 on my phone, and it behaves as expected, printing

Code:
00
10

What you're seeing in the display may not mean much because Free42 and the DM42 are a lot faster than the real HP-42S. If you want to verify the behavior of the program without relying on flag 21 being set, just add PSE instructions after both AVIEW instructions. And of course be aware that setting flag 21 in POFF mode causes AVIEW to stop program execution...
As I understand, AVIEW displays the Alpha register but does not stop program execution.
(05-19-2020 07:27 PM)mchris Wrote: [ -> ]As I understand, AVIEW displays the Alpha register but does not stop program execution.

It does when flag 21 is set while flag 55 is clear.
A lot of people seem to find this surprising, but this behavior goes all the way back to 1979 and the HP-41C.
I wonder how he can get 10, 10 and 00 in a row though, as stated in his original post. If the first time around you get 10, then F21 is not set, an execution was simply too fast for the 00 to show up. But then you should have gotten 00 and then 10 after, not the other way round?
Werner
(05-19-2020 08:09 PM)Werner Wrote: [ -> ]I wonder how he can get 10, 10 and 00 in a row though, as stated in his original post. If the first time around you get 10, then F21 is not set, an execution was simply too fast for the 00 to show up. But then you should have gotten 00 and then 10 after, not the other way round?
Werner

And that's what I saw on Free42, Emu42 and DM42
I understand that this is working correctly, but I'm still curious. How do you reproduce the behavior that mchris sees? The closest I can get this with flag 21 cleared:
- Enter the program
- XEQ "AAA"
Displays "10"
- Pres R/S
Display "00"
- Press R/S
Display "10"
- Press R/S
Back to normal display
Aha, I see it now.

The initial "00" is displayed so quickly you cannot see it, so you see the next display ("01") after it stops upon hitting the 1st RTN, then R/S advances through LBL-00 and stops again, displaying "00" and stops on the 2nd RTN, then R/S advances through LBL-01 and stops a 3rd time, displaying "01".

I guess I didn't realize that a RTN, with no pending return stack just does a STOP.
(05-19-2020 06:13 PM)rprosperi Wrote: [ -> ]
(05-19-2020 05:57 PM)toml_12953 Wrote: [ -> ]With Flag 21 set, I see 00 followed by 10 then the program ends, just as expected.

Thanks Tom, that was quick detective work! What on earth made you think of trying Flag-21 - just using AVIEW commands?

I saw that when Flag 21 wasn't set, all I saw was 10. I figured the display was going by too fast to see so I wanted AVIEW to stop until I pressed R/S. That lead me to Flag 21.
(05-19-2020 08:09 PM)Werner Wrote: [ -> ]I wonder how he can get 10, 10 and 00 in a row though, as stated in his original post. If the first time around you get 10, then F21 is not set, an execution was simply too fast for the 00 to show up. But then you should have gotten 00 and then 10 after, not the other way round?
Werner

Maybe I was wrong and it was 10, 00 and 10. I don't remember.
(05-19-2020 09:17 PM)rprosperi Wrote: [ -> ]The initial "00" is displayed so quickly you cannot see it, so you see the next display ("01") after it stops upon hitting the 1st RTN, then R/S advances through LBL-00 and stops again, displaying "00" and stops on the 2nd RTN, then R/S advances through LBL-01 and stops a 3rd time, displaying "01".
That is why I have added PSE instructions.

(05-19-2020 09:17 PM)rprosperi Wrote: [ -> ]I guess I didn't realize that a RTN, with no pending return stack just does a STOP.
Same behaviour on all RPN programmable since HP-67.
Pages: 1 2
Reference URL's