Next: 10.3.2 eflags.h: Processor flags
Up: (X86) Generic Low-level Definitions
Previous: (X86) Generic Low-level Definitions
#include <oskit/x86/asm.h>
This file contains convenience macros
useful when writing x86 assembly language code in AT&T/GAS syntax.
This header file is directly derived from Mach,
and similar headers are used in various BSD kernels.
The following macros allow assembly language code to be written
that coexists with C code compiled for either ELF or a.out format.
In a.out format,
by convention an underscore (_) is prefixed
to each public symbol referenced or defined by the C compiler;
however, the underscore prefix is not used in ELF format.
- EXT(name)
-
Evaluates to _name in a.out format,
or just name in ELF.
This macro is typically used
when referring to public symbols defined in C code.
- LEXT(name)
-
Evaluates to _name: in a.out format,
or name: in ELF.
This macro is generally used
when defining labels to be exported to C code.
- SEXT(name)
-
Evaluates to the string literal
"_name" in a.out format,
or "name" in ELF.
This macro can be used in GCC inline assembly code,
where the code is contained in a string constant;
for example:
asm("...; call "SEXT(foo)"; ...");
The following macros relate to alignment of code and data:
- TEXT_ALIGN
-
Evaluates to the preferred alignment of instruction entrypoints
(e.g., functions or branch targets),
as a power of two.
Currently evaluates to 4 (16-byte alignment)
if the symbol i486 is defined,
or 2 (4-byte alignment) otherwise.
- ALIGN
-
A synonym for TEXT_ALIGN.
- DATA_ALIGN
-
Evaluates to the preferred minimum alignment of data structures.
Currently it is always defined as 2,
although in some cases a larger value may be preferable,
such as the processor's cache line size.
- P2ALIGN(alignment)
-
Assembly language code can use this macro
to work around the fact that the .align directive
works differently in different x86 environments:
sometimes .align takes a byte count,
whereas other times it takes a power of two (bit count).
The P2ALIGN macro always takes a power of two:
for example, P2ALIGN(2) means 4-byte alignment.
By default, the P2ALIGN macro
uses the .p2align directive supported by GAS;
if a different assembler is being used,
then P2ALIGN should be redefined as
either .align alignment
or .align 1<<(alignment),
depending on the assembler's interpretation of .align.
XXX S_ARG, B_ARG, frame stuff, ...
XXX need to make the macros more easily overridable, using ifdefs.
XXX need to clean out old trash still in the header file
XXX IODELAY macro
Next: 10.3.2 eflags.h: Processor flags
Up: (X86) Generic Low-level Definitions
Previous: (X86) Generic Low-level Definitions
University of Utah Flux Research Group