Post Reply 
Is there a RPN operation that does nothing? (NOP)
01-04-2018, 02:44 AM
Post: #1
Is there a RPN operation that does nothing? (NOP)
What is the best RPN command (for say, 42s/free42) that does nothing?
A NOP operation.
  • Presumably setting or clearing a flag that nobody uses would do the trick - but strictly speaking has a side effect.
  • Two X<>Y operations would work but that's two operations, not one.
  • A label would work, but I don't want to use up a label or imply there is a related goto somewhere.

Any ideas?
Find all posts by this user
Quote this message in a reply
01-04-2018, 04:04 AM (This post was last modified: 01-04-2018 04:17 AM by Thomas Okken.)
Post: #2
RE: Is there a RPN operation that does nothing? (NOP)
(01-04-2018 02:44 AM)tcab Wrote:  What is the best RPN command (for say, 42s/free42) that does nothing?

Everything has the side effect of enabling stack lift, but assuming that's not a problem, one of several no-ops is STO ST X.

EDIT: "Several?" There aren't actually that many. The others I remember are X<> ST X and ├"".
On the 41, "", a synthetic construct which looks like it should clear the alpha register, is actually a no-op as well, and it's the only one that is one byte. I forget what it does on the 42S...
Visit this user's website Find all posts by this user
Quote this message in a reply
01-04-2018, 05:09 AM
Post: #3
RE: Is there a RPN operation that does nothing? (NOP)
LBL 00 through LBL 14 are one byte each.

http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, http://wilsonminesco.com/links.html )
Visit this user's website Find all posts by this user
Quote this message in a reply
01-04-2018, 05:46 AM
Post: #4
RE: Is there a RPN operation that does nothing? (NOP)
CHS CHS is about as close to a NOP as I can think of.
SHIFT SHIFT might be better but it doesn't actually do anything.


Pauli
Find all posts by this user
Quote this message in a reply
01-04-2018, 06:19 AM
Post: #5
RE: Is there a RPN operation that does nothing? (NOP)
The Text-0 instruction in the HP-41 pops in my mind as something that was suggested in the PPC days. It has to be created by synthetic means.

Håkan
Find all posts by this user
Quote this message in a reply
01-05-2018, 12:35 AM
Post: #6
RE: Is there a RPN operation that does nothing? (NOP)
(01-04-2018 06:19 AM)hth Wrote:  The Text-0 instruction in the HP-41 pops in my mind as something that was suggested in the PPC days. It has to be created by synthetic means.

Håkan

IIRC, for the HP41 this Text-0 is the fastest, shortest 'NOP', followed by the Lbl0-Lbl14, which is also one byte but slightly more wasteful as long programs often need more than 15 Lbl, meaning if one is used for a NOP, one needs to revert to 2-byte LBLs.
Non-Synthetic and not Lbl-wasteful is Sto St X (or X<> ST X).
Our kind host Dave has put up a fantastic "Synthetic 101" here which shows how to get a byte grabber all the way to 'LB'.

Cheers,

PeterP
Find all posts by this user
Quote this message in a reply
01-05-2018, 12:43 AM (This post was last modified: 01-05-2018 12:47 AM by Bill Duncan.)
Post: #7
RE: Is there a RPN operation that does nothing? (NOP)
(01-05-2018 12:35 AM)PeterP Wrote:  
(01-04-2018 06:19 AM)hth Wrote:  The Text-0 instruction in the HP-41 pops in my mind as something that was suggested in the PPC days. It has to be created by synthetic means.

Håkan

IIRC, for the HP41 this Text-0 is the fastest, shortest 'NOP', followed by the Lbl0-Lbl14, which is also one byte but slightly more wasteful as long programs often need more than 15 Lbl, meaning if one is used for a NOP, one needs to revert to 2-byte LBLs.
Non-Synthetic and not Lbl-wasteful is Sto St X (or X<> ST X).
Our kind host Dave has put up a fantastic "Synthetic 101" here which shows how to get a byte grabber all the way to 'LB'.

Remember that labels search forward on the 41. I often reuse the short one byte labels for short jumps forward (so they compile). Can't do it with loops of course, but short jumps over code are ripe for short label reuse.. I forget whether they enable stack lift or not..

My recent addition to the 41 library, Alarm (relative) manager reuses LBL 00 quite a bit for short jumps forward.
Find all posts by this user
Quote this message in a reply
01-05-2018, 02:10 AM
Post: #8
RE: Is there a RPN operation that does nothing? (NOP)
It looks like Text-0 doesn't work on the HP-42S. Free42 accepts it (you can paste "" as a program line) -- although it's not a NOP, rather it acts like CLA -- but when I created this program:

01 LBL "TEXT0"
02 ""
03 END

in Free42, then exported it to a raw file, and then loaded that raw file into Emu42, the result was

01 LBL "TEXT0"
02 :::
10080 END

Running it caused weirdness and then a Machine Reset. Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
01-05-2018, 03:12 AM
Post: #9
RE: Is there a RPN operation that does nothing? (NOP)
The STO X command for the HP-41C and HP-42S is a NOP.

Namir
Find all posts by this user
Quote this message in a reply
01-05-2018, 05:46 AM
Post: #10
RE: Is there a RPN operation that does nothing? (NOP)
(01-04-2018 04:04 AM)Thomas Okken Wrote:  On the 41, "", a synthetic construct which looks like it should clear the alpha register, is actually a no-op as well, and it's the only one that is one byte.
FWIW, this is F0h.

Greetings,

Matthias


--
"Programs are poems for computers."
Find all posts by this user
Quote this message in a reply
01-05-2018, 07:07 AM
Post: #11
RE: Is there a RPN operation that does nothing? (NOP)
(01-05-2018 02:10 AM)Thomas Okken Wrote:  It looks like Text-0 doesn't work on the HP-42S. Free42 accepts it (you can paste "" as a program line) -- although it's not a NOP, rather it acts like CLA -- but when I created this program:

01 LBL "TEXT0"
02 ""
03 END

in Free42, then exported it to a raw file, and then loaded that raw file into Emu42, the result was

01 LBL "TEXT0"
02 :::
10080 END

Running it caused weirdness and then a Machine Reset. Smile

It causes my decoder/encoder to crash as well. Nice find Smile
Find all posts by this user
Quote this message in a reply
01-05-2018, 08:26 AM
Post: #12
RE: Is there a RPN operation that does nothing? (NOP)
If you do not have a printer, you can use ADV
Cheers,Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
01-05-2018, 01:58 PM
Post: #13
RE: Is there a RPN operation that does nothing? (NOP)
On the 41, I usually just use a dummy label. It's not truly a no-op, since it causes the goose to advance, but that's close enough.
Visit this user's website Find all posts by this user
Quote this message in a reply
01-07-2018, 07:04 PM
Post: #14
RE: Is there a RPN operation that does nothing? (NOP)
For the HP-67 only, there's a weird, undocumented way to program a NOP:

- Enter GTO.2
- Press keys A and D simultaneously

This inserts the key code 32 24, which does nothing (there's no g (i) command).

The nice thing is that the command executes in a mere 7 ms.

Just for fun, I've added this NOP command to my RPN-67 and 97 simulators. Simply enter g (i), or EXT 0 on the RPN-97.

Willy
Find all posts by this user
Quote this message in a reply
01-08-2018, 07:40 AM
Post: #15
RE: Is there a RPN operation that does nothing? (NOP)
One more: CLD

Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
01-08-2018, 08:44 AM (This post was last modified: 01-08-2018 09:49 AM by Dieter.)
Post: #16
RE: Is there a RPN operation that does nothing? (NOP)
(01-08-2018 07:40 AM)Werner Wrote:  One more: CLD

CLD clears the display so that a VIEW or AVIEW message disappears. That's not quite "no operation". ;-)
Even without something in the display the 41's flying goose is reset to the left.

But when do you need a NOP on the 41 or 42? This happens essentially after an DSE or ISG command where only the decrement/increment is desired but not the final range check. Here in most cases the NOP step is never executed, so that it theoretically can be any command. However, if there is a chance that that step may be executed, I think a dummy label serves well (can be the same for every NOP throughout the program). If the next step enters a numeric value I ofter use an ENTER: there is no difference between "RCL 03" and "ENTER RCL 03" or "100" and "ENTER 100".

There are a lot of other options for a virtual NOP, depending on the rest of the program. If Alpha does not have to be preserved CLA will do. STO X has been mentioned, but it takes two bytes, so you may choose a register between 00 and 14 that at the moment is not in use. If your program runs in a certain angular mode you may simply set this mode again. If you know something about your x-value at that point of the program you may use a test that will always be true, e.g. x≠0? If two bytes are OK you may test one of the systems flags that always test clear, e.g. FC? 30 or FC? 54. So if a NOP is really required (which will not happen very often) there are numerous options.

Dieter
Find all posts by this user
Quote this message in a reply
01-08-2018, 10:54 AM
Post: #17
RE: Is there a RPN operation that does nothing? (NOP)
(01-08-2018 08:44 AM)Dieter Wrote:  CLD clears the display so that a VIEW or AVIEW message disappears. That's not quite "no operation". ;-)

Well, there is No Such Thing as a NOP in the 41/42.. they all have some side effect. CLD was used by HP themselves in their MATRIX code IIRC.

(01-08-2018 08:44 AM)Dieter Wrote:  If the next step enters a numeric value I ofter use an ENTER: there is no difference between "RCL 03" and "ENTER RCL 03" or "100" and "ENTER 100".

Never thought of that ;-) And never too old to learn, it seems. Thanks!

Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
01-08-2018, 12:28 PM
Post: #18
RE: Is there a RPN operation that does nothing? (NOP)
On the HP-41 you have also a “true” NOP instruction that appears as such in your program with the Paname module:

Quote: NOP - No Operation -

[NOP] (No OPeration) is used after a test, when the conditional goto is not used.
Find all posts by this user
Quote this message in a reply
01-08-2018, 12:46 PM
Post: #19
RE: Is there a RPN operation that does nothing? (NOP)
Not a true NOP because it (potentially) changes the angle mode but I tend to insert "RAD" where I just want do de-/increment a register.
Find all posts by this user
Quote this message in a reply
01-08-2018, 01:32 PM
Post: #20
RE: Is there a RPN operation that does nothing? (NOP)
None of the operations mentioned so far, other than STO ST X, X<> ST X, and ├"" (HP-42S / Free42) are true no-ops, they all depend on context for their do-nothingness.

Personally, I've never used any of these. The only reason I see to use them is to defeat the skip after ISG, which I prefer to do by not using ISG in that sense in the first place.

ISG 00
STO ST X

is inelegant; how about

1
STO+ 00

which has the virtue of making it absolutely clear what the programmer intends.

From the Jargon File:

Quote:program: n.
  1. A magic spell cast over a computer allowing it to turn one's input into error messages.
  2. An exercise in experimental epistemology.
  3. A form of art, ostensibly intended for the instruction of computers, which is nevertheless almost inevitably a failure if other programmers can't understand it.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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