Post Reply 
HP-41 FORTH; The most misunderstood Module?
04-12-2014, 08:31 AM (This post was last modified: 04-13-2014 06:24 AM by Ángel Martin.)
Post: #14
RE: HP-41 FORTH; The most misunderstood Module?
Thanks to Egan and Diego for sending the original ROM images - Now it's confirmed that the so called "CX Version" is *identical* to the original one, which let's remember that was meant to be used in pages #4 and #5.

Nomenclature:
We'll refer to the "Original Version" when the lower block is located in page#4 and the upper block is located in page#5. Conversely, we'll call "CX version" to the arrangement with the upper block located in page#7

The first fact to note is that within both blocks there are hard-coded calls to page#4 addresses (so far nothing new), but nowhere in either block are hard-coded calls to page #5.

This also confirms that the choice for page#7 to allocate the upper block in the "CX version" was the most unfortunate of all - since there are calls to HP-IL routines, therefore conflicting to it. In fact, any other page will work just fine because within the upper block all calls follow the port-dependent form, not hard-coded - as already mentioned.

Which functions make use of HP-IL routines, you may wonder? First off there is READEM and WRTEM, a carbon-copy of the PANAME functions of the same names (it's the French connection no doubt :-) But beware, because there are also calls hard-coded to page #7 within the lower block (in page #4) which are normally not executed - there seems to be a back-door triggered by CPU flag 1, I haven't figured out when that is active.

So as long as you don't use READEM / WRTEM you may be ok using the "CX version" - albeit not guaranteed due to that circumstance. BTW and FWIW, there was a bug in these that would send the execution to an infinite loop if no X-Memory was present - I fixed it, just a bad jump distance.

The upper block is needed for the OS polling point [CALC_ON], used to create a gigantic 198-register buffer, with id#=13. This is where all FORTH code would go, I guess.

Before you ask, using a bank-switched implementation to get rid of the page#4 dependency would be theoretically possible, but virtually impossible in practice due to the extensive use of the return stack (four levels used most of the time). Hard-coded calls to page#4 take just one RTN level and preserve the C register, whereas in a BS design the intra-bank calls take two levels and destroy the contents of C - so it'll take a complete re-write of the modules, not feasible at all.

The MCODE is very interesting, and shows a comfortable knowledge of the 41 OS. In fact some approaches are very creative and novel to this module, definitely the author knew his way around.

There are a couple of bugs I haven't figured out how to correct, like an undocumented CPU instruction (318 in address 49ED), and a call in addresses 4CCE/4CCF to address 3CBC in port#3 - which is obviously wrong given that this was designed for a 41C/CV.

I have attached the blueprints as promised. They're not 100% finished, so consider it a work in progress. Particularly discouraging is the fact that the upper block seems to have a lot of dead code, or unaccounted for (see gray fields on the addresses). This is baffling, I may be overlooking something but I have checked for alternative ways to re-direct the execution to those areas, (GOTOADR, manually PUSHADR, etc) finding no suitable matches. Let me know if you figure it out!

Also scattered around I marked the suspect lines with a "bug??" label in red.

Hope you enjoy this archaeological adventure - if no further discoveries occur I'd propose to rename this module the 'Science-Fiction" ROM ;-)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP-41 FORTH; The most misunderstood Module? - Ángel Martin - 04-12-2014 08:31 AM



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