🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.databases
Article #218

Using FoxBase with 32 bits addressing

#218
From: Maarten Carels
Date: Thu, 20 Aug 1992 15:05
140 lines
6204 bytes
When I tried to use FoxBase on a Quadra with 20 Mb of main memory, it
turned out that FoxBase (with companion programs) is not 32 bit clean.

Addresses the FoxBase gets from the system are stripped to 24 bits (that
means that the high order byte is cleared). While this works without
problems on machines that have less than 16 Megabytes of memory, it
gives serious problems when foxbase is loaded above address 16M. This is
just a plain coding fault from Fox. As Apple has documented in Inside
Mac for quite some time, it's almost never needed to strip the 8 extra
flag bits from memory addresses. You are even not supposed to know that
they are there. The only time you should strip an address (= remove
those extra bits) is when comparing two master pointers.

The system provides a function for this purpose, called StripAddress.
StripAddress knows how to remove those bits, and it also knows to leave
them alone if you are running with 32 bits addresses.

Now, back to FoxBase. The implementers choose to strip addresses they
get from the system by masking the address against the system variable
Lo3Bytes, which contains 0x00ffffff.
As said before, this causes problems when FoxBase lives above 16 M.

To solve this problem, I located all references to Lo3Bytes, and
designed a set of patches. One set is needed to fix FoxBase and the like
(FoxRun, MFoxBase, MFoxRun), the other set of patches treats FoxPackage
(the program you need to build a standalone application.

But, before we start, some disclaimers:
1. I'm not affiliated with Fox Software in any way, other than being a user of
   their programs.
2. These patches given below are for your enjoyment. I can take no
   responsability for them. They seem to work for me, however.
3. As always, patch a copy, not the original.

Before the patches, a short explanation what is actually changed (I
never liked getting patches without knowing what they do)

Most of them (the first set for both FoxBase and FoxPackage) search for one
instruction,
       AND.L    Lo3Bytes,D0
which removes the high byte of register D0.

We change that to
       _StripAddress
       NOP
StripAddress performs the function of stripping the address. The NOP
instruction (a no-op) does nothing, and is needed only to fill space. The
original AND.L instruction is 4 bytes long, and _StripAddress only 2. The
2 byte NOP instruction fills the leftover bytes without adverse effects.

The rest of the patches are more elaborate. Those contain also a AND.L
instruction, but a slightly different one:
       AND.L    Lo3Bytes,D1
StripAddress can't strip register D1, only D0.
So, at these places some more instructions are patched. Usually the old code is
like this:
       MOVE.L   ...,D1
       AND.L    Lo3Bytes,D1
which is changed into something like
       MOVE.L   ...,D0
       _StripAddress
       MOVE.L   D0,D1

At one place some more recoding was needed. This is the large patch for
CODE 5. Verifying what happens there is left as an exercise for the
interested reader :-)

And now the patches, in a 'Find this', 'Change into' style. Use a resource
editing tool, such as ResEdit, to apply them.
If you are not comfortable using tools like ResEdit, ask someone who is, or get
the manual (at your local bookshop), and familiarize yourself with ResEdit.

Patch set 1.
Apply these patches to the FoxBase, FoxRun, MFoxBase or MFoxRun programs. If
you use FoxPackage to build applications, apply these patches to both your
development version and the runtime version.

Open the program to patch. Get the list of CODE resources, and open CODE
2. Best (fastest anyway) is to open the Hex editor (keep option down
when you double click CODE 2). Get the Find Hex dialog and apply this
change:
   Find:      C0B8 031A
   Change to: A055 4E71
The pattern occurs 7 times in CODE 2. Be sure to change all of them.
Repeat the same to CODE 7 (1 time), CODE 8 (again 1 time) and CODE 27
(CODE 27 is only present in the development versions, not in the runtime
version. The pattern occurs 4 times. Change all of them).
Note that you can find the pattern also once in CODE 5. Do not change it there,
that occurence is handled later on.

Proceed with reopening CODE 2, there are some more patches needed there:
   Find:      2210 C2B8 031A
   Change to: 2010 A055 2200
(This pattern occurs two times. Be sure to change both)

Next, one more for CODE 2:
   Find:      220F C2B8 031A
   Change to: 200F A055 2200
(Only one time)

Up to the last, and most elaborate one
Open CODE 5. Apply this patch (it's a large one!)
   Find:      2010 C0B8 031A D0AE FFF8 206E 0006 2210
   Change to: 2010 A055 2200 D2AE FFF8 206E 0006 2010
                   ^^^^ ^^^^ ^^^^                ^^^^
   Find:      C2B8 031A 2F2E FFFC 2F01 2F00 4EAD
   Change to: A055 4E71 2F2E FFFC 2F00 2F01 4EAD
              ^^^^ ^^^^           ^^^^ ^^^^

And that's all.  Save, and you should have a FoxBase that works with large
amounts of memory.

-----------
Next, the patches needed for FoxPackage (the program that puts together the
stuff that you have written with a runtime engine to create standalone
applications). Most of them are quite like what's needed to patch the other
programs. All patches are to be applied to CODE 2.

We start with:
   Find:      C0B8 031A
   Change to: A055 4E71
(8 times. Be sure to change all of them)

Second:
   Find:      2210 C2B8 031A
   Change to: 2010 A055 2200
(Two times. Be sure to change both of them)

And the last one:
   Find:      220F C2B8 031A
   Change to: 200F A055 2200

And that's all for FoxPackage.

--maarten
-- 
In real life:	Maarten Carels
		Computer Science Department
		University of Amsterdam
email:		maarten@fwi.uva.nl
Technical Details
Message-ID: <1992Aug20.150531.29319@fwi.uva.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!fwi.uva.nl!maarten

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.mac.databases
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!fwi.uva.nl!maarten
From: maarten@fwi.uva.nl (Maarten Carels)
Subject: Using FoxBase with 32 bits addressing
Message-ID: <1992Aug20.150531.29319@fwi.uva.nl>
Sender: news@fwi.uva.nl
Nntp-Posting-Host: mail.fwi.uva.nl
Organization: FWI, University of Amsterdam
Date: Thu, 20 Aug 1992 15:05:31 GMT
Lines: 140