04-19-2016, 02:49 PM
Pages: 1 2
04-19-2016, 03:21 PM
(04-19-2016 02:49 PM)wojtek Wrote: [ -> ]How would you determine the number of data registers set in the past (and forgotten) in the HP41C?
There is no SIZE? command in this calculator.
This is a question people had been asking since the machine was introduced. It was solved relatively early on in the PPC ROM with the "S?" (Size Finder) routine, which contains a call to another routine within the module. If you can't get your hands on a PPC ROM module, perhaps others here can chime in with a reasonable alternative.
Jake
04-19-2016, 03:42 PM
(04-19-2016 02:49 PM)wojtek Wrote: [ -> ]How would you determine the number of data registers set in the past (and forgotten) in the HP41C?Very simple. Start RCL-ing from maximum possible register number down. Depending on how much memory is available will take you less than a minute to figure it out.
There is no SIZE? command in this calculator.
04-19-2016, 04:11 PM
(04-19-2016 03:42 PM)RMollov Wrote: [ -> ](04-19-2016 02:49 PM)wojtek Wrote: [ -> ]How would you determine the number of data registers set in the past (and forgotten) in the HP41C?Very simple. Start RCL-ing from maximum possible register number down. Depending on how much memory is available will take you less than a minute to figure it out.
There is no SIZE? command in this calculator.
:-) :-) good joke, thank you, I know that way of course.
Less than a minute? Even if you have quad memory installed?
04-19-2016, 07:12 PM
(04-19-2016 04:11 PM)wojtek Wrote: [ -> ]...Less than a minute? Even if you have quad memory installed?
Bisection search rather than sequential?
04-19-2016, 07:39 PM
(04-19-2016 07:12 PM)BobVA Wrote: [ -> ](04-19-2016 04:11 PM)wojtek Wrote: [ -> ]...Less than a minute? Even if you have quad memory installed?
Bisection search rather than sequential?
Maybe. Allowing for the worst case - 317 data registers it would take 8 steps:
318/159/240/270/295/307/313/316=HIT (or something like this)
I would rather think about a procedure based on bisection search and hit or miss rule and using the flag 25 - error ignore.
04-19-2016, 08:40 PM
(04-19-2016 02:49 PM)wojtek Wrote: [ -> ]How would you determine the number of data registers set in the past (and forgotten) in the HP41C?
There is no SIZE? command in this calculator.
In the early HP41 days, SIZE finders were among the most popular routines. They could be found in several issues of HP key notes and most probably many similar publications. With the advent of Synthetic Programming, faster synthetic versions became available. And of course the PPC ROM includes such a function. You may take a look at the books by Bill Wickes and/or the documentation of the mentioned ROM.
Eventually the X-Functions module became available, and so the problem was solved by the included SIZE? command. Since it offers many other useful functions, I would recommend getting such a module.
Dieter
04-19-2016, 08:55 PM
(04-19-2016 04:11 PM)wojtek Wrote: [ -> ]:-) :-) good joke, thank you, I know that way of course.
Less than a minute? Even if you have quad memory installed?
Hmmm... I tried this very (!) simple program...
Code:
LBL"SIZE??"
,4
SIGN
SF 25
LBL 01
RCL IND L
FC? 25
GTO 02
ISG L
GTO 01
LBL 02
LastX
INT
END
... and my physical '41 required 9 seconds for SIZE 050. So even in the worst case the result indeed should appear within about a minute. ;-)
Dieter
04-19-2016, 11:06 PM
(04-19-2016 08:55 PM)Dieter Wrote: [ -> ]Hmmm... I tried this very (!) simple program...
Code:
LBL"SIZE??"
,4
SIGN
SF 25
LBL 01
RCL IND L
FC? 25
GTO 02
ISG L
GTO 01
LBL 02
LastX
INT
END
... and my physical '41 required 9 seconds for SIZE 050. So even in the worst case the result indeed should appear within about a minute. ;-)
Dieter
It took 17 secs to find out there were 100 registers allocated on my beast (which I already knew anyway). Nice program BTW, I love watching the flying goose.
Cheers,
04-20-2016, 04:57 AM
The following program (64 bytes) will find the number of registers in nine lookup. (160, 80, 40, 20, 10, 5, 3, 2, 1)
On a unmodified HP-41CX Halfnut, the program consistently runs in 5.7 seconds.
Measured with the stopwatch
Insert after LBL "SIZE?" -> 0, SETSW, RUNSW
Insert before END -> STOPSW, RCLSW, X<>Y
Have fun!
Sylvain
Edit: add run time
Code:
01 LBL "SIZE?" // Entry Point
02 SF 25 // Start with substraction
03 0 // Register index
04 320 // Register offset (startup value, max number of registers)
05 LBL 00 // Loop
06 2 //
07 / // Divide register offset by 2
08 .5 //
09 + // Add .5 for odd divisions
10 INT // Get interger part
11 FS? 25 // If last memory access was valid
12 + // Add register offset to register index
13 FC? 25 // If last memory access was invalid
14 - // Substract register offset from register index
15 LASTX // Get back register offset
16 SF 25 // Ignore next error
17 RCL IND Y // Memory access request
18 FS? 25 // If successful
19 RDN // Drop unneeded recalled value
20 1 // Exit loop condition
21 X=Y? //
22 GTO 01 // leave loop if the offset is 1
23 RDN // Drop exit loop test value
24 GTO 00 // Loop for next iteration
25 LBL 01 // Almost done
26 RDN // Drop exit loop test value
27 RDN // Drop register offset
28 SF 25 // Ignore next error
29 RCL IND X // Memory access request
30 FC? 25 // If last memory access was invalid
31 GTO 02 // Odd number of registers allocated, no compensation needed
32 RDN // Drop unneeded recalled value
33 1 // Even number of registers allocated, compensation needed
34 + // Compensate the value found by 1
35 LBL 02 // Compensation terminated
36 X<0? // If the number is negative, thene there was no data register allocated
37 0 // 0 for no data registers
38 END // The number of registers has been found
On a unmodified HP-41CX Halfnut, the program consistently runs in 5.7 seconds.
Measured with the stopwatch
Insert after LBL "SIZE?" -> 0, SETSW, RUNSW
Insert before END -> STOPSW, RCLSW, X<>Y
Have fun!
Sylvain
Edit: add run time
04-20-2016, 08:40 AM
Here's my non-synthetic version, 36 bytes without the END
Cheers, Werner
*Edited a few times. Now, after 25 years or so, I seem to be able to find improvements I couldn't find before..
Code:
>LBL"SIZE?"
255
ENTER
ISG X
>LBL 01
SF 25
VIEW IND Y
CLD
FC?C 25
CHS
2
/
ST+ Y
ABS
INT
X>0?
GTO 01
RDN
LASTX
+
END
Cheers, Werner
*Edited a few times. Now, after 25 years or so, I seem to be able to find improvements I couldn't find before..
04-20-2016, 12:03 PM
(04-19-2016 11:06 PM)RMollov Wrote: [ -> ]It took 17 secs to find out there were 100 registers allocated on my beast
Twice the SIZE, twice the time. ;-)
But...
(04-19-2016 11:06 PM)RMollov Wrote: [ -> ]Nice program BTW, I love watching the flying goose.
...OK, it's a nice program for goose watchers, but otherwise it's simply stupid. #-)
I also tried a bisection method, and this runs in about 5 seconds for any SIZE.
Dieter
04-21-2016, 11:14 AM
(04-20-2016 08:40 AM)Werner Wrote: [ -> ]Here's my non-synthetic version, 36 bytes without the ENDI find that fenomenon too myself. Kudos btw, as usual.
...
*Edited a few times. Now, after 25 years or so, I seem to be able to find improvements I couldn't find before..
Cheers
04-21-2016, 11:27 AM
Some 30+ years ago, a structural engineer I worked for had a 41cv program to calculate if pile depth is enough to support future structure or something; I only did surveying work for him. The program used to run for more than 5 hours, sometimes 6 or 7. We used to sit in the pub nearby watching the flying goose while sipping gin and tonic and other similar stuff. That was great! That's how I fell in love with the goose.
04-21-2016, 05:24 PM
(04-20-2016 08:40 AM)Werner Wrote: [ -> ]*Edited a few times. Now, after 25 years or so, I seem to be able to find improvements I couldn't find before..
I prefer the original version – the new one is slightly shorter (while I doubt it's faster), but the display looks a bit weird because of the VIEW / CLD sequence.
Here's another option that does not require a second flag test:
Code:
>LBL"SIZE?"
255
ENTER
ISG X
>LBL 01
SF 25
ENTER
CLX
RCL IND Z
RDN
FC?C 25
CHS
2
/
ST+ Y
ABS
INT
X>0?
GTO 01
X<> L
+
END
The CLX disables stack lift so that the RCL overwrites X if the register is available, otherwise it leaves a zero.
Otherwise I really like your code. It's short, fast and effective.
Dieter
04-21-2016, 05:49 PM
Couple of items from PPC Journal issues, just for the fun of it.
HP-41C Shortest Size Finder by Rolf R. Schmitt - 21 bytes
PPC Calculator Journal V7 N8 P26 October 1980
HP-41C Short Size Finder Routine by Geoff Smith - 25 bytes
PPC Calculator Journal V7 N6 Pg 36 Jul/Aug 1980
HP-41C Size Finder Routine by Justus A. Villa - 31 bytes[/php]
PPC Calculator Journal V7 N6 P36 Jul/Aug 1980
HP-41C Small Size Finder Routine by Ron Knapp - 34 bytes
PPC Calculator Journal V7 N2 P38 Feb-Mar 1980
HP-41C Shortest Size Finder by Rolf R. Schmitt - 21 bytes
PPC Calculator Journal V7 N8 P26 October 1980
Code:
01 LBL "S" ;Shortest Size Finder Routine
02 0
03 SF 25
04 LBL 01
05 VIEW IND X
06 FS? 25
07 ISG X
08 STOP
09 GTO 01
10 END
HP-41C Short Size Finder Routine by Geoff Smith - 25 bytes
PPC Calculator Journal V7 N6 Pg 36 Jul/Aug 1980
Code:
01 LBL "S" ;Short Size Finder Routine
02 .5
03 SF 25
04 LBL 01
05 VIEW IND X
06 ISG X
07 FS? 25
08 GTO 01
09 1.5
10 -
11 END
HP-41C Size Finder Routine by Justus A. Villa - 31 bytes[/php]
PPC Calculator Journal V7 N6 P36 Jul/Aug 1980
Code:
01 LBL "S" ;Size Finder Routine
02 257
03 ENTER
04 LBL 00
05 2
06 /
07 SF 25
08 ARCL IND Y
09 FC? 25
10 CHS
11 +
12 LASTX
13 ABS
14 INT
15 X#0?
16 GTO 00
17 +
18 RTN
19 END
HP-41C Small Size Finder Routine by Ron Knapp - 34 bytes
PPC Calculator Journal V7 N2 P38 Feb-Mar 1980
Code:
01 LBL "S" ;Small Size Finder Routine
02 9
03 -1
04 512
05 LBL 00
06 2
07 /
08 SF 25
09 ST+ Y
10 ABS
11 ARCL IND Y
12 FC?C 25
13 CHS
14 DSE Z
15 GTO 00
16 X<0?
17 CLX
18 +
19 RTN
04-21-2016, 07:19 PM
(04-21-2016 05:24 PM)Dieter Wrote: [ -> ]Code:
>LBL"SIZE?"
255
ENTER
ISG X
>LBL 01
SF 25
ENTER
CLX
RCL IND Z
RDN
FC?C 25
CHS
2
/
ST+ Y
ABS
INT
X>0?
GTO 01
X<> L
+
END
The CLX disables stack lift so that the RCL overwrites X if the register is available, otherwise it leaves a zero.
Otherwise I really like your code. It's short, fast and effective.
Dieter
The previous version at 37 bytes used almost exactly that trick. Almost, since ENTER itself also disables stack lift and so the CLX is not needed ;-))
And I tried out the VIEW/CLD on a real 41, the VIEWs do not show, that's why I thought it was acceptable.
Cheers, Werner
And now I'm going to read Gene's post ;-)
04-21-2016, 07:38 PM
(04-21-2016 07:19 PM)Werner Wrote: [ -> ]The previous version at 37 bytes used almost exactly that trick. Almost, since ENTER itself also disables stack lift and so the CLX is not needed ;-))
Arrrrgghh... *facepalm*
OK, I was really blind here. #-)
(04-21-2016 07:19 PM)Werner Wrote: [ -> ]And I tried out the VIEW/CLD on a real 41, the VIEWs do not show, that's why I thought it was acceptable.
I do not like the goose jumping back on every CLD.
Among the versions posted by Gene some use ARCL instead of RCL so that the stack is not affected. I wonder if this may slow down the program.
Dieter
04-22-2016, 04:16 AM
(04-20-2016 08:40 AM)Werner Wrote: [ -> ]Here's my non-synthetic version, 36 bytes without the ENDI got rid of CLD and replaced VIEW IND Y with ARCL IND Y and it's now slightly quicker plus the goose flies smoooothly
Code:
>LBL"SIZE?"
255
ENTER
ISG X
>LBL 01
SF 25
VIEW IND Y
CLD
FC?C 25
CHS
2
/
ST+ Y
ABS
INT
X>0?
GTO 01
RDN
LASTX
+
END
Cheers, Werner
*Edited a few times. Now, after 25 years or so, I seem to be able to find improvements I couldn't find before..
Cheers
04-22-2016, 05:36 AM
(04-21-2016 07:38 PM)Dieter Wrote: [ -> ]I do not like the goose jumping back on every CLD.
Among the versions posted by Gene some use ARCL instead of RCL so that the stack is not affected. I wonder if this may slow down the program.
Dieter
The goose jumping backward doesn't bother me - the MATRIX program in the standard module used CLD as a NOP after ISG, so it showed that behaviour, too.
I didn't want to use ARCL, I always try to use as few resources as possible.
Also, again I must praise Free42: did you know that (for any x)
SF 25
SIZE x
ENTER
RCL x
still has stack lift disabled? I didn't. But that's how it is in the 41 and 42. And Free42.
Werner
Pages: 1 2