Somebody having a clever substitute for the CLRGX command?
|
09-29-2024, 06:14 PM
Post: #1
|
|||
|
|||
Somebody having a clever substitute for the CLRGX command?
Hello all,
does anyone in this distinguished forum have a substitute function for the CLRGX command for use on a non-CX HP41? I wouldn't mind it using X-functions, but HEPAX commands are out of the question. If I'd write this myself, I'd probably do a loop over the given register interval, just counting up the numbers, and set the register with those numbers equal to zero. Is assume there is a better way, possibly with a command I don't know? Any help appreciated, thanks, emefff. [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
09-29-2024, 07:37 PM
Post: #2
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
(09-29-2024 06:14 PM)emefff Wrote: substitute function for the CLRGX command for use on a non-CX HP41? I wouldn't mind it using X-functions, but HEPAX commands are out of the question.I think this is the way to go. The X-Functions module won't help here. Ok, you could construct something using REGMOVE if you have a predefined block of cleared registers beforehand, but that would be more effort than just running a simple loop for the task. (09-29-2024 06:14 PM)emefff Wrote: Is assume there is a better way, possibly with a command I don't know?Not without any external hardware IMHO. -- Ray |
|||
09-30-2024, 09:24 AM
(This post was last modified: 09-30-2024 09:29 AM by emefff.)
Post: #3
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Hello,
thank you for taking time. I just realized: for a 100% substitute I also need to implement a kind of stepping as the original command reads: CLRGX Clear registers by X (bbb.eeeii). Clear every iith register from Rbbb through Reee. That's a bit more than I expected... oh my. I don't even know how to check the length of eeeii (is it only eee or eeeii), and also what about wrong entries of bbb.eeeii? Yuck! emefff. [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
09-30-2024, 09:38 AM
(This post was last modified: 10-01-2024 06:53 AM by Stephan61.)
Post: #4
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Quick and dirty:
Code: 01 LBL "CLRGX" 15CE,41CV,48GX,71B,DM41X |
|||
09-30-2024, 09:51 AM
(This post was last modified: 09-30-2024 02:29 PM by Werner.)
Post: #5
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
(09-29-2024 06:14 PM)emefff Wrote: does anyone in this distinguished forum have a substitute function for the CLRGX command for use on a non-CX HP41? If you don't mind a few synthetic commands, I wrote this quite a while ago, it's part of my much larger 'Basic subroutines' pack: (if the entry for CLRGX contains an increment ii>1, there can be no gain over the simple loop. But clearing a contiguous block using the technique below is surprisingly fast, even on a real '41) -- -- b0: contiguous block clear -- 65-Byte Prgm including END -- -- L X Y Z T 01 LBL"b0" a,b 02 ENTER -- size check 03 FRC 04 E3 05 * b a,b 06 STO IND X 07 5 -- simple loop vs Σ-loop 08 - 09 X<Y? 10 GTO 00 b-5 a,b 11 RCL Y 12 INT 13 ,06 14 + a,6 b-5 a,b a,b 15 E3 16 / 17 + b-5,a,6 a,b a,b a,b 18 RCL c -- ΣREG? 19 ΣREG IND Z 20 CLΣ 21 RCL b -- LBL 05 22 ΣREG IND Z <-+ 23 CLΣ | 24 DSE Z | 25 STO b --+ GTO 05 26 Rv 27 STO c -- ΣREG IND X 28 RTN 29 LBL 00 -- 6 elements or less, simple loop 30 CLX -- -- bI: intitialize counter in Y with value in X -- 31 LBL"bI" 32 LBL 06 33 STO IND Y 34 ISG Y 35 GTO 06 36 END Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
09-30-2024, 10:08 AM
(This post was last modified: 09-30-2024 10:28 AM by emefff.)
Post: #6
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Oh that was quick, I think I got it:
Code: 01 LBL CLRGX2 # substitute for CLRGX on non-CX HP41s Thank you Werner, I will try yours as well. My code doesn't check anything LOL. We are using the same amount of lines, VERY interesting! :-) emefff. [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
09-30-2024, 02:33 PM
Post: #7
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
I updated my program, putting non-synthetic alternatives in comments, but of course ΣREG? is also only in the CX, not in the X-Functions module. If you don't mind ΣREG to be affected, this is a non-synthetic version:
-- -- b0: contiguous block clear -- 59-Byte Prgm including END -- -- L X Y Z T 01 LBL"b0" a,b 02 ENTER -- size check 03 FRC 04 E3 05 * b a,b 06 STO IND X 07 5 -- simple loop vs Σ-loop 08 - 09 X<Y? 10 GTO 00 b-5 a,b 11 RCL Y 12 INT 13 ,06 14 + a,6 b-5 a,b a,b 15 E3 16 / 17 + b-5,a,6 a,b a,b a,b 18 ΣREG IND Y 19 CLΣ 20 LBL 05 21 ΣREG IND X 22 CLΣ 23 DSE X 24 GTO 05 25 RTN 26 LBL 00 -- 6 elements or less, simple loop 27 CLX -- -- bI: intitialize counter in Y with value in X -- 28 LBL"bI" 29 LBL 06 30 STO IND Y 31 ISG Y 32 GTO 06 33 END Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
09-30-2024, 04:33 PM
(This post was last modified: 09-30-2024 04:34 PM by Didier Lachieze.)
Post: #8
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
If you don’t mind something slower but also shorter and which leaves the stack unchanged excepted X and L here is a simple routine compatible with the basic HP-41C that you should be able to use as a CLRGX replacement:
Code: 01 LBL "CLRGX" Start with bbb.eeeii in X, it will clear every ii register from register bbb up to register eee (if ii is 0 the increment used is 1, so to clear every register from 12 to 18 just enter 12.018 XEQ "CLRGX"). |
|||
09-30-2024, 05:09 PM
(This post was last modified: 09-30-2024 05:24 PM by emefff.)
Post: #9
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Seems elegant, I have one problem though: How do I enter the second line, respectively every line with L? XEQ alpha X shift I shift J alpha .... then I'm stuck....
EDIT: I gave up too early... XEQ alpha X shift I shift J alpha ST L That's it. I have no idea what's going on here, but it seems to work! Compared to my solution it seems like magic. Thanks Didier! [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
09-30-2024, 05:35 PM
(This post was last modified: 09-30-2024 05:36 PM by emefff.)
Post: #10
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
@Stephan: sorry, I overlooked your solution, maybe because it is so short :-). In fact, Didier's is similar to yours. Thank you also for this very elegant solution!
emefff [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
09-30-2024, 06:07 PM
Post: #11
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command? | |||
09-30-2024, 06:45 PM
(This post was last modified: 09-30-2024 06:54 PM by emefff.)
Post: #12
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Thank you Thomas, danke!
Is this becoming a competition? :-) [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
09-30-2024, 09:24 PM
Post: #13
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command? | |||
10-01-2024, 02:11 AM
Post: #14
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
(09-30-2024 06:45 PM)emefff Wrote: Thank you Thomas, danke! It's pretty much inevitable here... but it's OK as one can learn soooo much by reading the increasingly elegant solutions, as they evolve, getting slightly smaller, or faster, and often both! --Bob Prosperi |
|||
10-01-2024, 06:19 AM
Post: #15
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
(09-29-2024 06:14 PM)emefff Wrote: I wouldn't mind it using X-functions, but HEPAX commands are out of the question. Hi, How about this one? Code: 01 LBL "CLRX" To clear register AAA up to BBB, just enter AAA.BBB XEQ "CLRX" Register X and Y are preserved, alpha lost, and register [AAA,BBB] are cleared. I.e. 5.015 XEQ "CLRX" clears register 5 up to and including 15. The pros of this one, is that it is quite fast - especially for larger number of registers (no loops). The big drawback is that it need X-Memory, and there must (temporarily) be space for a file with the same number of registers as to be cleared, and the file "X" (or other unique name) must not be present (no error check in this little routine) ... But, if speed is wanted (and MCode routines are out of question) ... Cheers, Thomas [35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X] |
|||
10-01-2024, 08:28 AM
(This post was last modified: 10-01-2024 08:37 AM by J-F Garnier.)
Post: #16
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Inspired by Thomas' solution:
- Step 1 (to be done only once): create a 319-reg data file on a mass storage unit: 319 "ZEROREG" CREATE - Step 2: use this CLRX program: Code: 01 LBL "CLRX" HP-IL needed, as well as a (possibly virtual) mass storage unit. But all registers preserved, except ALPHA. J-F |
|||
10-01-2024, 09:13 AM
Post: #17
|
|||
|
|||
RE: Somebody having a clever substitute for the CLRGX command?
Thank you all, I underestimated the enthusiasm. But then I think it is a useful command to have on every HP41, not only the CX.
emefff [35, 45, 41CV, 41CX, 12c, 15c, 15CE, 28S, 42s, 48GX, DM15L, DM42, DM41X, wp34s, wp34s_on_DM42, 35S, Prime, IVEE] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)