In support of the 33s & 35s
|
01-04-2018, 07:00 PM
(This post was last modified: 01-05-2018 11:31 AM by Dieter.)
Post: #48
|
|||
|
|||
RE: In support of the 33s & 35s
(01-04-2018 01:21 PM)pier4r Wrote: Thanks for the test and the result still baffles me. Then take a look at the results below. ;-) First of all, I think I was wrong about the memory usage of numeric constants. My knowledge essentially was what BartDB said: any numeric constant takes 37 bytes. But I think this is wrong and the 37 bytes refer to the memory used by the data registers, including the 800 indirect ones on the 35s. For numbers in programs it looks like it's actually 3 bytes plus one more byte for each digit / decimal point / E / sign. So a simple "3" requires four bytes. Regular 33s/35s commands occupy 3 bytes, so "pi IP" is 6 bytes, i.e. two bytes more than a plain 3. But indeed the execution speed significantly varies with the way constants are used in 35s programs. Here is an example with 100 loops of adding 3√3+3 where the constant "3" is coded in different ways: Code: B001 LBL B This straightforward, plain vanilla code runs in about 17,5 s. Next version: Code: B001 LBL B Replacing the number "3" with pi IP speeds up the program: The above code runs in about 14 s. Here's another version, this time using LastX: Code: B001 LBL B Avoiding two out of three numeric constants gives a significant boost compared to the first version: The above code runs in only 13 s, comparable to the previous pi IP version, but requiring two steps less per loop which may account for the slight difference. And yet another version: Code: B001 LBL B Using RCL and avoiding inline numbers completely speeds up the program even more. The above code requires just about 10 s. And finally this one: Code: B001 LBL B Using RCL-Arithmetics saves two lines and squeezes out one more second. The above code now runs in about 9 s. So it looks like you can almost double the execution speed of this program by choosing the right method that best fits the 35s. Finally, here is another example with three different numeric constants: Code: B001 LBL B The standard version runs in about 17,5 s just as the first program. This could be expected as only the values of the three constants are different. Now try replacing 3, 2 and 1 with other commands: Code: B001 LBL B Although this version has more steps per loop, avoiding the three numeric constants and replacing them with IP(pi), IP(e) and sign(pi) yields a speedup which makes the program finish in merely 13,5 seconds. Finally an "ENTER +" instead of the multiplication saves another second so that we get below 13 s. Now, why are regular inline numbers so slow? I suspect this is because they are handled as equations. This would also match their memory usage (3+n bytes). Equations have to be parsed each time the program comes across one, and this requires some time. (01-04-2018 08:38 AM)grsbanks Wrote:(01-04-2018 08:06 AM)Dieter Wrote: LBL C is not required, the 35s can branch to any program line. So remove LBL C and GTO B007 instead. This way the loop also is one step shorter. I don't think that removing the second label from Antonio's code yields any significant speedup (except for one step less per loop) as the 35s does not search labels the way classic HPs did: there is no "GTO C", i.e. "search for label C and continue there". The code is "GTO C001", i.e. "branch to line 001 of program C". So I don't think there is a speed difference between "GTO C001" and "GTO B007". In both cases it's (more or less) direct line addressing. Dieter Edit: corrected a few listings, especially line numbers |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)