Post Reply 
42S local label caching
11-17-2019, 03:16 PM
Post: #20
RE: 42S local label caching
Almost all information was told so far. So I could only make a review from the aspect of the Emu42 RAW file import "Edit/Load Object..." when emulating a HP42S.

1) The FOCAL programs of the HP41 and the HP42S are binary compatible. The exception is Synthetic Code, the HP42S don't support synthetic programming. So Emu42 allows importing FOCAL programs saved by the V41 "File/Put User Code..." feature.

2) Joe stated correctly:
(11-14-2019 10:54 PM)Joe Horn Wrote:  One exception to code equality between the 41 and 42S was discovered by Tom Cadwallader (cf. end of above article): The 41 adds a non-packable null between sequential numbers in program memory, but the 42S adds a null after ALL numbers, not just between them. This will result in most 42S programs being slightly larger than their 41 equivalent.

This is a major problem when importing FOCAL's from V41. First of all I had to add all the null bytes after numbers on one side, on the other side the HP42S has no pack command, so it would be useful to eliminate all the nulls from the import file. This is a two pass process. In pass one I count the number of bytes required to allocate program buffer in calculator memory, therefore I don't count any null byte and only count the null bytes necessary at end of a number. Then allocate the memory and in pass two the data is copied under respect of the null bytes. Both inserting and removing of null bytes change the distance between labels.

3) Global Labels: The global labels are connected of over a global chain in one direction. So the offset to the previous global label is saved in the byte code of a global label. So at importing due the fact of inserting and removing nulls bytes I have to recalculate the global label offsets. This happens also when I add programs to the memory at end. The process includes recalculating the global label offset to get a correct link between the global labels.

4) Local Labels: I wasn't aware of local label caching and so the import function failed sometimes when loading FOCAL's from V41. This was fixed more or less recently at Emu42 v1.22. Since this version the import function overwrites the offset part of local labels with 0 bits. At the first run of the program the HP42S recalculates each offset. This I quite important doing benchmarks. Directly after importing a FOCAL program into Emu42 all local labels are not cached, so you get only repeatable results after the first run.

5) Importing FOCAL programs from Emu42 into V41: When you may have a look into the V41 sources about importing FOCALS you don't see anything about recalculation of the chain of global labels or removing the offsets in the local labels. The difference is, the import at V41 do not add or remove null bytes, so all distances are still ok after loading. To get rid of the additional null bytes at end of every number when importing from Emu42 just call the PACK command in the HP41.

6) Remark to Joe, you don't need a real HP42 and you don't need the internal memory scanner. The memory viewer inside the Debugger of Emu42 was good enough for me exploring the inner working of memory allocation inside the HP42 OS. :)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
42S local label caching - Dave Britten - 11-11-2019, 05:54 PM
RE: 42S local label caching - Sylvain Cote - 11-11-2019, 06:18 PM
RE: 42S local label caching - Dave Britten - 11-11-2019, 06:56 PM
RE: 42S local label caching - Sylvain Cote - 11-13-2019, 02:00 PM
RE: 42S local label caching - Sylvain Cote - 11-13-2019, 02:06 PM
RE: 42S local label caching - Andres - 11-11-2019, 07:06 PM
RE: 42S local label caching - Dave Britten - 11-11-2019, 07:28 PM
RE: 42S local label caching - Sylvain Cote - 11-14-2019, 04:00 AM
RE: 42S local label caching - Joe Horn - 11-14-2019, 10:54 PM
RE: 42S local label caching - Sylvain Cote - 11-15-2019, 05:42 PM
RE: 42S local label caching - Joe Horn - 11-15-2019, 09:48 PM
RE: 42S local label caching - Sylvain Cote - 11-16-2019, 03:25 PM
RE: 42S local label caching - Werner - 11-16-2019, 04:50 PM
RE: 42S local label caching - Sylvain Cote - 11-16-2019, 11:33 PM
RE: 42S local label caching - Sylvain Cote - 11-16-2019, 11:22 PM
RE: 42S local label caching - Joe Horn - 11-17-2019, 12:50 PM
RE: 42S local label caching - Werner - 11-17-2019, 09:37 AM
RE: 42S local label caching - J-F Garnier - 11-17-2019, 09:51 AM
RE: 42S local label caching - Werner - 11-17-2019, 07:03 PM
RE: 42S local label caching - Christoph Giesselink - 11-17-2019 03:16 PM



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