Next | Prev | Up | Top | Contents | Index
Predefined Variables
The predefined variables are set by the compiler or assembler when they are invoked. These variables will have different values depending on which switches are used on the command line. These variables can then be used by conditional compilation directives such as #ifdef to determine which code gets compiled or assembled for a particular ABI. You can see the values of these predefined variables by adding the -show switch to a compilation command. The variable that can help distinguish between on32 and n32 compilations are the following:
For MipsI o32 executables:
-D_MIPS_FPSET=16
-D_MIPS_ISA=_MIPS_ISA_MIPS1
-D_MIPS_SIM=_MIPS_SIM_ABI32
For MipsIV N32 executables:
-D_MIPS_FPSET=32
-D_MIPS_ISA=_MIPS_ISA_MIPS4
-D_MIPS_SIM=_MIPS_SIM_ABIN32
The explanation of these predefines is as follows:
- MIPS_ISA is Mips Instruction Set Architecture. MIPS_ISA_MIPS1 and MIPS_ISA_MIPS4 are the most common variants for assembler code. MIPS_ISA_MIPS4 is the ISA for R8000 applications.
- MIPS_SIM denotes the Mips Subprogram Interface Model.This describes the subroutine linkage convention and register naming/usage convention. It indicates o32 n32 or n64.
- _MIPS_FPSET describes the number of floating point registers. The Mips IV compilation model makes use of the extended floating point registers available on the R4000 and beyond.
The following code fragment shows an example of the use of these macros:
#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2)
#define SZREG 4
#endif
#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
#define SZREG 8
#endif
Next | Prev | Up | Top | Contents | Index