HP Articles Forum
[Return to the Index ]
[ Previous | Next ]
41-MCODE: Dr. Jekyll & Mr. Hyde
Posted by Ángel Martin on 7 July 2012, 3:48 a.m.
I recently spent a little time experimenting with ideas to overcome the 64-function FAT limitation.
As the title suggest, this is about using alternative (or parallel) FATs for the same module (say it´s a 4k ROM). The situation is therefore that there is empty room left in the page to add more functions, but no more FAT entries are available (yes, we´ve all been here before many times...)
The idea is to use a couple of routines and their corresponding tables to re-write the FAT "on demand", thus the dual-personality concept. Such a dynamic re-writing can only be done when the module is located in RAM, be that the HEPAX, the MLDL2k, or - of course- the CL sRAM, plenty of pages there...
FAT-A would include the "MRHYDE" function, so you can switch to the FAT-B arrangement; and conversely the FAT-B would have the "DJEKYLL" routine to switch back.
This can also be implemented as an auto check upon the calculator-ON event, using the polling points to prompt which choice you want to start with. This would not require the two functions, although they´ve grown on me already, and besides they can always be used for safety.
Note that there´s no bank-switching involved. I first considered this approach but unfortunately (for this purpose but very fortunately for many others) the CL system always returns to the first bank when the calculator goes into ligh sleep, thus a hypothetical bank-2 FAT even if it existed wouldn´t hold a chance; let´s say it wouldn´t "stick" :-)
As example, let´s see how the ALPHA ROM outgrows its capabilities to have a total of 70 functions, split in 41 and 29 for each group.
The switching routines are as follows:
Header A05B 08C "L" Header A05C 00C "L" Header A05D 019 "Y" Header A05E 00B "K" Header A05F 005 "E" Header A060 00A "J" Header A061 004 "D" DJEKIL A062 35D ?NC XQ Refresh C[3,6] A063 000 ->00D7 PCTOC A064 09C PT= 5 A065 04A C=0 R<- A066 0FA C<>B M Write-To adr in B[M] A067 0DA C=B M A068 3D0 LD@PT- F A069 090 LD@PT- 2 "pF1F" A06A 1D0 LD@PT- 7 address of FAT-B table A06B 083 JNC +16d Header A06C 085 "E" Header A06D 004 "D" Header A06E 019 "Y" Header A06F 008 "H" Header A070 012 "R" Header A071 00D "M" MRHYDE A072 35D ?NC XQ Refresh C[3,6] A073 000 ->00D7 PCTOC A074 09C PT= 5 A075 04A C=0 R<- clear rest of ADR field A076 0FA C<>B M Write-To adr A077 0DA C=B M keep it in C[ADR] A078 390 LD@PT- E A079 390 LD@PT- E "pEE8" A07A 210 LD@PT- 8 address of FAT-A table A07B 330 FETCH S&X read source word A07C 0FA C<>B M swap addresses A07D 040 WROM write word to target A07E 23A C=C+1 M increase target adr A07F 0FA C<>B M recall source adr A080 23A C=C+1 M increase source adr A081 2F6 ?C#0 XS end of table? A082 3CB JNC -07 no, loop back A083 3E0 RTN yes, done.
and the tables are just an exact copy of the respective FAT´s, including the two zero words at the end, and followed by any word with a non-zero value in the XS field - which marks the end of the table to the read-write routines.
The FATS have each one extra function, to activate the parallel versions. So FAT-A includes ¨MRHYDE¨ and FAT-B includes ¨DJEKYLL¨.
The requirement impossed here is obviously the additional space required by the two tables and the switching routines (snipets really). A maximum of 128 functions (of which two are the housekeeping ones) can be accomodated, requiring 272 (2x136) words for the tables - but that´s the worst-case scenario.
a FOCAL program requiring a function on the "other" FAT will simple use the "personality function" to activate it first, then back (or not depending on what comes next). To be on the safe side one can always add such call with flag 25 to trap errors in case the FAT is already the active one.
Really can´t be any simpler, and it´s a lot of fun to watch. Email me if you want a copy of the ALPHA44 module to play with, and by all means let´s keep thinking on a way to eliminate that nasty restriction in better ways...
Edited: 9 July 2012, 9:08 a.m.
[ Return to the Message Index ]
Go back to the main exhibit hall