Post Reply 
Somebody having a clever substitute for the CLRGX command?
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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Somebody having a clever substitute for the CLRGX command? - Werner - 09-30-2024 09:51 AM



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