Technical Q&As


PLAT 01 - Code Resources Larger Than 32K (1-May-95)


Q I'm trying to write a 4D external (stand-alone code) which will be larger than 32K. When I compile my C code with model -far, the linker tells me:

### Link: Error: Linker does not edit 32-bit instructions. (Error 29)

Is there an example showing a MPW generated >32K standalone code resource?

A Model far works by patching parts of the segment loading mechanism, changing the structure of jump table entries, and storing segment relocation information for the generation of absolute addresses. This only applies to applications, however, which is why the Linker is generating an error.

The restriction in creating >32K CODE resources is only because of limitations with intra-segment branching. Depending on the compiler options you use, this can be worked around. For example, the MPW C compiler has the -bigseg option, which creates one big CODE resource with all function calls within the same segment to be BSR.L instruction. Since BSR.L is a PC-relative instruction with a 32-bit offset, the 32K restriction is eliminated. (However, these code resources will only work on Macintoshes with 68020s or later).

Another option you can use with the MPW Linker is -br on. This creates branch islands that are less than 32K apart for overall jumps within a CODE resource that are greater than 32K. This method has the advantage of being able to work on 68000 Macintoshes, but it can make your code larger and slower.

To find out more about both options, we suggest looking through the MPW Command Reference under C and Linker. Also, check out the Runtime Architecture chapter in "Building Programs with MPW," available with MPW.

Unfortunately, there aren't any samples showing how these samples are used, but it should be just a matter of adding options to your MakeFile.

Technical Q&As
Contents | Next Question