Contents

" Specify align size"

This allows you to control the maximum alignment used by the compiler. Some CPUs (including those in the Intel 80x86 family) access data faster if it is aligned on an address which is a multiple of the size of the data. Suppose the CPU is accessing a real which is 8 bytes long, then for fastest access, the real should be on an address which is a multiple of 8 (for example 0, 8, 16, 24, 32, etc).

The compiler stores variables in memory at the lowest available address which is a multiple of either the variable's size or the maximum alignment, whichever is smaller.

For example suppose you compile the following program and the maximum alignment is 4.

     program x(output);
     var
        c : char;
        i : integer;
        b : boolean;
        r : real;
     begin
     end.

The compiler needs to decide where to store the variables c, i, b and r. The first variable c gets stored at address 0, and since c is a char variable (which are 1 byte long) the available addresses are from 1 upwards. The second variable i is an integer variable (which are 4 bytes long). The lowest available address which is a multiple of the variable size is 4 and the lowest available address which is a multiple of the maximum alignment is also 4. So the compiler stores i at address 4, and the available address are from 8 upwards (since i is 4 bytes long). The third variable b is a boolean variable (which are 4 bytes long). The lowest available address which is a multiple of the variable size is 8 and the lowest available address which is a multiple of the maximum alignment is also 8. So the compiler stores b at address 8, and the available address are from 12 upwards (since b is 4 bytes long). The fourth variable r is a real variable (which are 8 bytes long). The lowest available address which is a multiple of the variable size is 16 but the lowest available address which is a multiple of the maximum alignment is 12. So the compiler stores r at address 12 (since 12 is less than 16).

In general if you set maximum alignment to 1 then you waste no memory but you get fastest access only for chars. If you set the maximum alignment to 4 you may waste memory when storing all variables except char, but you get the fastest access to all variables except real. If you set the maximum alignment to 8 you may waste memory when storing all variables except char, but you get the fastest access to variables of all types.

If you are not sure about the maximum alignment to use just leave the default (4).

Contents