NOP on HP-41C - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: NOP on HP-41C (/thread-15933.html) Pages: 1 2 |
NOP on HP-41C - Benoit Maag - 11-21-2020 09:58 PM Likely a question that came up decades ago... what is the fastest way to implement NOP on a 41C without disturbing the stack? I have been using FIX 5 - is there a better way? Related to this, is it faster to use: ISG 00 FIX 5 (NOP) or: 1 STO+00 RE: NOP on HP-41C - Thomas Okken - 11-21-2020 10:36 PM You can find out which is faster by simply trying it. Try both options, have them run for a few seconds, and see how far they count when running the same amount of time. If the instruction following the ISG is guaranteed to always be skipped, it doesn't matter what you put there or what side effects it has. You could use, say, DEG, because it takes only 1 byte. Or, my personal preference, use something that has no side effects at all, to make it clear what is intended; efficiency isn't the only concern when programming, making it easy to read and understand is also a good idea. A nice straightforward NOP for the 41C is STO X. RE: NOP on HP-41C - Valentin Albillo - 11-21-2020 10:58 PM (11-21-2020 09:58 PM)Benoit Maag Wrote: Likely a question that came up decades ago... what is the fastest way to implement NOP on a 41C without disturbing the stack? I have been using FIX 5 - is there a better way? Something like LBL 00 is best both as a NOP and after that ISG: it only takes 1 byte, has no side effects and executes fastest. Also, the ISG is faster than the 1, STO+ and doesn't affect the stack so it doesn't lose T. V. RE: NOP on HP-41C - Massimo Gnerucci - 11-22-2020 12:00 AM X <> X RE: NOP on HP-41C - Thomas Okken - 11-22-2020 12:35 AM (11-22-2020 12:00 AM)Massimo Gnerucci Wrote: X <> X STO X is 2.75 ms faster which of course only matters if it is ever actually executed and probably not even then RE: NOP on HP-41C - Gene - 11-22-2020 12:39 AM Synthetic programming came up with TEXT 0 as the apparently preferred NOP to use. Does not affect the stack or ALPHA and is faster (?) than the other options ? Of course, requires synthetic programming, but I'm never without Angel's masterpiece roms so no problem. RE: NOP on HP-41C - Sylvain Cote - 11-22-2020 12:43 AM The ultimate NOP is the synthetic TEXT 0 (0xF0). With the ZenROM, in program mode, you XEQ "NOP" and it will enter the 0xF0 code in your program, otherwise you can always use the byte loader program. Edit: Gene was faster than me. RE: NOP on HP-41C - Thomas Okken - 11-22-2020 12:50 AM (11-22-2020 12:43 AM)Sylvain Cote Wrote: The ultimate NOP is the synthetic TEXT 0 (0xF0). Hmm. I have been thinking about how to add a NOP instruction to Free42 in a backward-compatible manner, and I had completely forgotten about TEXT 0. It fits the bill perfectly! Nice, I'll go ahead and use that, then. RE: NOP on HP-41C - Gene - 11-22-2020 01:34 AM Great Thomas! RE: NOP on HP-41C - Benoit Maag - 11-22-2020 02:01 AM Thank you all for all the options! RE: NOP on HP-41C - Namir - 11-22-2020 02:48 AM I use: STO X Namir RE: NOP on HP-41C - Benoit Maag - 11-22-2020 03:38 PM Thank you all for all the options! RE: NOP on HP-41C - Werner - 12-28-2020 12:25 PM (11-22-2020 12:50 AM)Thomas Okken Wrote: Hmm. I have been thinking about how to add a NOP instruction to Free42 in a backward-compatible manner, and I had completely forgotten about TEXT 0. It fits the bill perfectly! Nice, I'll go ahead and use that, then. a SKIP instruction would also be nice, but there is no 1-byte equivalent that will always work ;-) You might wonder where a SKIP instruction would be useful. If you have two tests, A (eg. X=Y?) and B (eg FS? 25), how would you implement: 1. if A or B then x; y; end : 01 ^A 02 B 03 SKIP 04 GTO 00 05 x 06 y 07 LBL 00 2. if A and B then x; end 01 A 02 ^B 03 SKIP 04 x I've always managed to find 1-byte always-false-fillers to use as skip, though ;-) Cheers, Werner RE: NOP on HP-41C - Namir - 12-28-2020 01:56 PM A general emulation for NOP for all calculators that support subroutines is a call to an empty subroutine. This is a solution for the desperate! :-) Namir RE: NOP on HP-41C - Dave Britten - 12-28-2020 02:17 PM (11-21-2020 10:58 PM)Valentin Albillo Wrote: Something like LBL 00 is best both as a NOP and after that ISG: it only takes 1 byte, has no side effects and executes fastest. It has one small side effect: it will potentially move the goose if the LBL is "executed". But I think most people can live with that - I typically use LBL 00 myself. RE: NOP on HP-41C - Valentin Albillo - 12-28-2020 03:37 PM (12-28-2020 02:17 PM)Dave Britten Wrote:(11-21-2020 10:58 PM)Valentin Albillo Wrote: Something like LBL 00 is best both as a NOP and after that ISG: it only takes 1 byte, has no side effects and executes fastest. If speed is wanted, as in this Fastest NOP case, leaving the goose merrily fly is a bad idea as it usually entails many display refreshes which somewhat slow down program execution (most noticeable in some emulators). I always have my programs execute "WAIT...", AVIEW at the very beginning to get rid of the goose for good. Looks more "pro" too. P.S.: It seems DM42 creators also noticed this because in DM42 you can clear a specific bit in variable RefLCD to disable the goose flight and so avoid the slowdown altogether. Regards. V. RE: NOP on HP-41C - Dave Britten - 12-28-2020 05:57 PM (12-28-2020 03:37 PM)Valentin Albillo Wrote: If speed is wanted, as in this Fastest NOP case, leaving the goose merrily fly is a bad idea as it usually entails many display refreshes which somewhat slow down program execution (most noticeable in some emulators). I always have my programs execute "WAIT...", AVIEW at the very beginning to get rid of the goose for good. Looks more "pro" too. Very true. I'm guessing many large application programs end up VIEWing something, thus hiding the goose. Has anybody benchmarked the effect of having the goose visible vs. having VIEW/AVIEW visible when passing a label? I could whip up a little program on my 41CX that times execution for, say, 1000 loop iterations, and run it both with and without an initial AVIEW. RE: NOP on HP-41C - hth - 12-28-2020 06:51 PM (12-28-2020 05:57 PM)Dave Britten Wrote: Very true. I'm guessing many large application programs end up VIEWing something, thus hiding the goose. Has anybody benchmarked the effect of having the goose visible vs. having VIEW/AVIEW visible when passing a label? I could whip up a little program on my 41CX that times execution for, say, 1000 loop iterations, and run it both with and without an initial AVIEW. Each move of the goose costs 15 cycles extra compared to if a message is shown. The code is: Code:
RE: NOP on HP-41C - Dave Britten - 12-28-2020 08:15 PM (12-28-2020 06:51 PM)hth Wrote:(12-28-2020 05:57 PM)Dave Britten Wrote: Very true. I'm guessing many large application programs end up VIEWing something, thus hiding the goose. Has anybody benchmarked the effect of having the goose visible vs. having VIEW/AVIEW visible when passing a label? I could whip up a little program on my 41CX that times execution for, say, 1000 loop iterations, and run it both with and without an initial AVIEW. Interesting, what does that translate to in microseconds? (Assuming a perfectly calibrated CPU clock, of course.) RE: NOP on HP-41C - Sylvain Cote - 12-28-2020 08:37 PM (12-28-2020 06:51 PM)hth Wrote: Each move of the goose costs 15 cycles extra compared to if a message is shown. (12-28-2020 08:15 PM)Dave Britten Wrote: Interesting, what does that translate to in microseconds? (Assuming a perfectly calibrated CPU clock, of course.) In the old HP 41 CPU speed thread John Ioannidis says the HP-41 process 6300 machine instructions per second or 1 instruction per 158.730 microseconds. So assuming that this is a good estimation and that all instructions take the same amount of time to execute, which I doubt, the goose move subroutine (15 cycles) would takes 2.381 milliseconds to execute. |