Next: , Previous: Set elements, Up: Top

8 geta4 and other things - some words on code and data models

A program consists of two portions - code and data (with the exception of self modifying code - you cannot get this out of GCC and it is a bad thing to do - so forget about it).

A program usually accesses them in a unique style of addressing modes for the machine instructions - called a code (or data) model.

On the amiga OS there exist two addressing styles for both of them - code and data. With full 32 bit addresses - giving you access to 4 GB of address space. And with reduced 16 bit addresses - giving you access to only 32k of code and 64k of data. These styles are called large (or normal) and small code and data models. Usually small code comes together with small data - but that's not necessary.

(Don't mix code and data models with the memory models of MS-DOS machines: The memory in small data model is still flat 4 GB which means by using pointers you can still address the whole memory. Only the number of variables is limited.)

You may think that these limitations are a large disadvantage - where are the benefits?

The benefits are simple: Code size and performance.

Every time you access a 16 bit address instead of 32 bit you spare 2 bytes in code size meaning 2 bytes in program size. And the processor needs to load and process a smaller instruction that needs less processor cycles. And since these 16 bit addresses are relative the loader of the OS need not relocate them. Meaning that you spare even 8 bytes more in executable size and some loading time.

And there is another advantage: If all the data is addressed relative it is simple to relocate it at program start - which means that you can easily get multientrant and reentrant executables (the code section is constant and need not be relocated). You know these as pure=resident programs.

Some details: