home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / database / 1014 < prev    next >
Encoding:
Text File  |  1992-08-20  |  5.9 KB  |  152 lines

  1. Newsgroups: comp.sys.mac.databases
  2. Path: sparky!uunet!mcsun!sun4nl!fwi.uva.nl!maarten
  3. From: maarten@fwi.uva.nl (Maarten Carels)
  4. Subject: Using FoxBase with 32 bits addressing
  5. Message-ID: <1992Aug20.150531.29319@fwi.uva.nl>
  6. Sender: news@fwi.uva.nl
  7. Nntp-Posting-Host: mail.fwi.uva.nl
  8. Organization: FWI, University of Amsterdam
  9. Date: Thu, 20 Aug 1992 15:05:31 GMT
  10. Lines: 140
  11.  
  12. When I tried to use FoxBase on a Quadra with 20 Mb of main memory, it
  13. turned out that FoxBase (with companion programs) is not 32 bit clean.
  14.  
  15. Addresses the FoxBase gets from the system are stripped to 24 bits (that
  16. means that the high order byte is cleared). While this works without
  17. problems on machines that have less than 16 Megabytes of memory, it
  18. gives serious problems when foxbase is loaded above address 16M. This is
  19. just a plain coding fault from Fox. As Apple has documented in Inside
  20. Mac for quite some time, it's almost never needed to strip the 8 extra
  21. flag bits from memory addresses. You are even not supposed to know that
  22. they are there. The only time you should strip an address (= remove
  23. those extra bits) is when comparing two master pointers.
  24.  
  25. The system provides a function for this purpose, called StripAddress.
  26. StripAddress knows how to remove those bits, and it also knows to leave
  27. them alone if you are running with 32 bits addresses.
  28.  
  29. Now, back to FoxBase. The implementers choose to strip addresses they
  30. get from the system by masking the address against the system variable
  31. Lo3Bytes, which contains 0x00ffffff.
  32. As said before, this causes problems when FoxBase lives above 16 M.
  33.  
  34. To solve this problem, I located all references to Lo3Bytes, and
  35. designed a set of patches. One set is needed to fix FoxBase and the like
  36. (FoxRun, MFoxBase, MFoxRun), the other set of patches treats FoxPackage
  37. (the program you need to build a standalone application.
  38.  
  39. But, before we start, some disclaimers:
  40. 1. I'm not affiliated with Fox Software in any way, other than being a user of
  41.    their programs.
  42. 2. These patches given below are for your enjoyment. I can take no
  43.    responsability for them. They seem to work for me, however.
  44. 3. As always, patch a copy, not the original.
  45.  
  46. Before the patches, a short explanation what is actually changed (I
  47. never liked getting patches without knowing what they do)
  48.  
  49. Most of them (the first set for both FoxBase and FoxPackage) search for one
  50. instruction,
  51.        AND.L    Lo3Bytes,D0
  52. which removes the high byte of register D0.
  53.  
  54. We change that to
  55.        _StripAddress
  56.        NOP
  57. StripAddress performs the function of stripping the address. The NOP
  58. instruction (a no-op) does nothing, and is needed only to fill space. The
  59. original AND.L instruction is 4 bytes long, and _StripAddress only 2. The
  60. 2 byte NOP instruction fills the leftover bytes without adverse effects.
  61.  
  62. The rest of the patches are more elaborate. Those contain also a AND.L
  63. instruction, but a slightly different one:
  64.        AND.L    Lo3Bytes,D1
  65. StripAddress can't strip register D1, only D0.
  66. So, at these places some more instructions are patched. Usually the old code is
  67. like this:
  68.        MOVE.L   ...,D1
  69.        AND.L    Lo3Bytes,D1
  70. which is changed into something like
  71.        MOVE.L   ...,D0
  72.        _StripAddress
  73.        MOVE.L   D0,D1
  74.  
  75. At one place some more recoding was needed. This is the large patch for
  76. CODE 5. Verifying what happens there is left as an exercise for the
  77. interested reader :-)
  78.  
  79. And now the patches, in a 'Find this', 'Change into' style. Use a resource
  80. editing tool, such as ResEdit, to apply them.
  81. If you are not comfortable using tools like ResEdit, ask someone who is, or get
  82. the manual (at your local bookshop), and familiarize yourself with ResEdit.
  83.  
  84. Patch set 1.
  85. Apply these patches to the FoxBase, FoxRun, MFoxBase or MFoxRun programs. If
  86. you use FoxPackage to build applications, apply these patches to both your
  87. development version and the runtime version.
  88.  
  89. Open the program to patch. Get the list of CODE resources, and open CODE
  90. 2. Best (fastest anyway) is to open the Hex editor (keep option down
  91. when you double click CODE 2). Get the Find Hex dialog and apply this
  92. change:
  93.    Find:      C0B8 031A
  94.    Change to: A055 4E71
  95. The pattern occurs 7 times in CODE 2. Be sure to change all of them.
  96. Repeat the same to CODE 7 (1 time), CODE 8 (again 1 time) and CODE 27
  97. (CODE 27 is only present in the development versions, not in the runtime
  98. version. The pattern occurs 4 times. Change all of them).
  99. Note that you can find the pattern also once in CODE 5. Do not change it there,
  100. that occurence is handled later on.
  101.  
  102. Proceed with reopening CODE 2, there are some more patches needed there:
  103.    Find:      2210 C2B8 031A
  104.    Change to: 2010 A055 2200
  105. (This pattern occurs two times. Be sure to change both)
  106.  
  107. Next, one more for CODE 2:
  108.    Find:      220F C2B8 031A
  109.    Change to: 200F A055 2200
  110. (Only one time)
  111.  
  112. Up to the last, and most elaborate one
  113. Open CODE 5. Apply this patch (it's a large one!)
  114.    Find:      2010 C0B8 031A D0AE FFF8 206E 0006 2210
  115.    Change to: 2010 A055 2200 D2AE FFF8 206E 0006 2010
  116.                    ^^^^ ^^^^ ^^^^                ^^^^
  117.    Find:      C2B8 031A 2F2E FFFC 2F01 2F00 4EAD
  118.    Change to: A055 4E71 2F2E FFFC 2F00 2F01 4EAD
  119.               ^^^^ ^^^^           ^^^^ ^^^^
  120.  
  121. And that's all.  Save, and you should have a FoxBase that works with large
  122. amounts of memory.
  123.  
  124. -----------
  125. Next, the patches needed for FoxPackage (the program that puts together the
  126. stuff that you have written with a runtime engine to create standalone
  127. applications). Most of them are quite like what's needed to patch the other
  128. programs. All patches are to be applied to CODE 2.
  129.  
  130. We start with:
  131.    Find:      C0B8 031A
  132.    Change to: A055 4E71
  133. (8 times. Be sure to change all of them)
  134.  
  135. Second:
  136.    Find:      2210 C2B8 031A
  137.    Change to: 2010 A055 2200
  138. (Two times. Be sure to change both of them)
  139.  
  140. And the last one:
  141.    Find:      220F C2B8 031A
  142.    Change to: 200F A055 2200
  143.  
  144. And that's all for FoxPackage.
  145.  
  146. --maarten
  147. -- 
  148. In real life:    Maarten Carels
  149.         Computer Science Department
  150.         University of Amsterdam
  151. email:        maarten@fwi.uva.nl
  152.