Post Reply 
DM42 and labels
05-19-2020, 04:26 PM (This post was last modified: 05-19-2020 04:31 PM by mchris.)
Post: #1
DM42 and labels
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 05:19 PM
Post: #2
RE: DM42 and labels
(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

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 05:30 PM
Post: #3
RE: DM42 and labels
(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.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-19-2020, 05:39 PM
Post: #4
RE: DM42 and labels
(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!
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 05:52 PM
Post: #5
RE: DM42 and labels
Further testing...
The problem occurs only when an AVIEW function exists inside the subroutine. It somehow destroys the return stack or something like that.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 05:57 PM
Post: #6
RE: DM42 and labels
(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

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
05-19-2020, 06:01 PM
Post: #7
RE: DM42 and labels
...and adding a STOP after the AVIEW solves the problem!
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 06:10 PM
Post: #8
RE: DM42 and labels
(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
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 06:13 PM (This post was last modified: 05-19-2020 06:15 PM by Sylvain Cote.)
Post: #9
RE: DM42 and labels
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
Find all posts by this user
Quote this message in a reply
05-19-2020, 06:13 PM
Post: #10
RE: DM42 and labels
(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?

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-19-2020, 07:12 PM
Post: #11
RE: DM42 and labels
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...
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 07:27 PM (This post was last modified: 05-19-2020 07:30 PM by mchris.)
Post: #12
RE: DM42 and labels
As I understand, AVIEW displays the Alpha register but does not stop program execution.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 07:56 PM
Post: #13
RE: DM42 and labels
(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.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 08:09 PM
Post: #14
RE: DM42 and labels
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

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
05-19-2020, 08:26 PM
Post: #15
RE: DM42 and labels
(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

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 08:54 PM
Post: #16
RE: DM42 and labels
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
Find all posts by this user
Quote this message in a reply
05-19-2020, 09:17 PM
Post: #17
RE: DM42 and labels
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.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-19-2020, 10:06 PM
Post: #18
RE: DM42 and labels
(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.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
05-19-2020, 10:18 PM
Post: #19
RE: DM42 and labels
(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.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2020, 10:53 PM
Post: #20
RE: DM42 and labels
(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.
Find all posts by this user
Quote this message in a reply
Post Reply 




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