[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

7. i386 Backend

This chapter documents the Backend for the Intel i386 processor family.


7.1 Additional options for this version

This backend provides the following additional options:

-longalign

Align multibyte-values on 4-byte-boundaries. Needed by some operating systems.

-elf

Do not use a ’_’-prefix in front of external identifiers. Use a ’.’-prefix for label names.

-merge-constants

Place identical floating point constants at the same memory location. This can reduce program size and increase compilation time.

-const-in-data

By default constant data will be placed in a read-only section. Using this option it will be placed in the data section Note that on operating systems with memory protection this option will disable write-protection of constant data.

-no-delayed-popping

By default arguments of function calls are not always popped from the stack immediately after the call, so that the arguments of several calls may be popped at once. With this option vbcc can be forced to pop them after every function call. This may simplify debugging and very slightly reduce the stack size needed by the compiled program.

-safe-fp

Do not use the floating-point-stack for register variables. At the moment this is necessary as vbcci386 still has problems in some cases otherwise.


7.2 ABI

This backend supports the following registers:

(And %st(0)-%st(7) for the floating point stack but these must not bes used for register variables because they cannot be handled like normal registers.)

The current version generates assembly output for use with the GNU assembler. The generated code should work on systems with Intel 80386 or higher CPUs with FPU and compatible chips.

The registers %eax, %ecx and %edx (as well as the floating point stack) are used as scratch registers (i.e. they can be destroyed in function calls), all other registers are preserved.

All elementary types up to 4 bytes are returned in register %eax Floating point values are returned in %st(0). All other types are returned by passing the function the address of the result as a hidden argument - so when you call such a function without a proper declaration in scope you can expect a crash.

vbcc uses %eax, %ebx, %ecx, %edx, %esi, %edi, %ebp and the floating point stack for temporary results and register variables. Local variables are created on the stack and addressed via %esp.

The elementary data types are represented like:

 
    type        size in bits        alignment in bytes (-longalign)

    char                8                       1 (1)
    short              16                       2 (4)
    int                32                       2 (4)
    long               32                       2 (4)
    long long          n/a                      n/a
    all pointers       32                       2 (4)
    float              32                       2 (4)
    double             64                       2 (4)
    

7.3 Predefined Macros

This backend defines the following macros:

__I386__
__X86__

7.4 Stdarg

A possible <stdarg.h> could look like this:

 
    typedef unsigned char *va_list;

    #define va_start(ap, lastarg) ((ap) = (va_list)(&lastarg + 1))
    #define va_arg(ap, type) ((ap) += \
      (sizeof(type)<sizeof(int)?sizeof(int):sizeof(type)), ((type *)(ap))[-1])
    #define va_end(ap) ((ap) = 0L)

7.5 Known Problems


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by vb on January 3, 2015 using texi2html 1.82.