libyasm
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
coretype.h File Reference

YASM core types and utility functions. More...

Go to the source code of this file.

Data Structures

struct  yasm_stdmac
 Standard macro structure for modules that allows association of a set of standard macros with a parser/preprocessor combination. More...
 
struct  yasm_assoc_data_callback
 YASM associated data callback structure. More...
 
struct  yasm_value
 A value. More...
 

Macros

#define YASM_LIB_DECL
 
#define YASM_VALUE_RSHIFT_MAX   127
 Maximum value of yasm_value.rshift.
 

Typedefs

typedef struct yasm_arch yasm_arch
 Architecture instance (mostly opaque type). More...
 
typedef struct yasm_preproc yasm_preproc
 Preprocessor interface. More...
 
typedef struct yasm_parser yasm_parser
 Parser instance (mostly opaque type). More...
 
typedef struct yasm_objfmt yasm_objfmt
 Object format interface. More...
 
typedef struct yasm_dbgfmt yasm_dbgfmt
 Debug format interface. More...
 
typedef struct yasm_listfmt yasm_listfmt
 List format interface. More...
 
typedef struct yasm_objfmt_module yasm_objfmt_module
 Object format module interface. More...
 
typedef struct yasm_dbgfmt_module yasm_dbgfmt_module
 Debug format module interface. More...
 
typedef struct yasm_stdmac yasm_stdmac
 Standard macro structure for modules that allows association of a set of standard macros with a parser/preprocessor combination. More...
 
typedef struct
yasm_assoc_data_callback 
yasm_assoc_data_callback
 YASM associated data callback structure. More...
 
typedef struct yasm_errwarns yasm_errwarns
 Set of collected error/warnings (opaque type). More...
 
typedef struct yasm_bytecode yasm_bytecode
 Bytecode. More...
 
typedef struct yasm_object yasm_object
 Object. More...
 
typedef struct yasm_section yasm_section
 Section (opaque type). More...
 
typedef struct yasm_symtab yasm_symtab
 Symbol table (opaque type). More...
 
typedef struct yasm_symrec yasm_symrec
 Symbol record (opaque type). More...
 
typedef struct yasm_expr yasm_expr
 Expression. More...
 
typedef struct yasm_intnum yasm_intnum
 Integer value (opaque type). More...
 
typedef struct yasm_floatnum yasm_floatnum
 Floating point value (opaque type). More...
 
typedef struct yasm_value yasm_value
 A value. More...
 
typedef struct yasm_linemap yasm_linemap
 Line number mapping repository (opaque type). More...
 
typedef struct yasm_valparam yasm_valparam
 Value/parameter pair (opaque type). More...
 
typedef struct yasm_valparamhead yasm_valparamhead
 List of value/parameters (opaque type). More...
 
typedef struct yasm_directive yasm_directive
 Directive list entry. More...
 
typedef struct yasm_effaddr yasm_effaddr
 An effective address. More...
 
typedef struct yasm_insn yasm_insn
 An instruction. More...
 
typedef enum yasm_expr_op yasm_expr_op
 Expression operators usable in yasm_expr expressions. More...
 
typedef int(* yasm_output_value_func )(yasm_value *value, unsigned char *buf, unsigned int destsize, unsigned long offset, yasm_bytecode *bc, int warn, void *d)
 Convert yasm_value to its byte representation. More...
 
typedef int(* yasm_output_reloc_func )(yasm_symrec *sym, yasm_bytecode *bc, unsigned char *buf, unsigned int destsize, unsigned int valsize, int warn, void *d)
 Convert a symbol reference to its byte representation. More...
 

Enumerations

enum  yasm_expr_op {
  YASM_EXPR_IDENT, YASM_EXPR_ADD, YASM_EXPR_SUB, YASM_EXPR_MUL,
  YASM_EXPR_DIV, YASM_EXPR_SIGNDIV, YASM_EXPR_MOD, YASM_EXPR_SIGNMOD,
  YASM_EXPR_NEG, YASM_EXPR_NOT, YASM_EXPR_OR, YASM_EXPR_AND,
  YASM_EXPR_XOR, YASM_EXPR_XNOR, YASM_EXPR_NOR, YASM_EXPR_SHL,
  YASM_EXPR_SHR, YASM_EXPR_LOGIC, YASM_EXPR_LOR, YASM_EXPR_LAND,
  YASM_EXPR_LNOT, YASM_EXPR_LXOR, YASM_EXPR_LXNOR, YASM_EXPR_LNOR,
  YASM_EXPR_LT, YASM_EXPR_GT, YASM_EXPR_EQ, YASM_EXPR_LE,
  YASM_EXPR_GE, YASM_EXPR_NE, YASM_EXPR_NONNUM, YASM_EXPR_SEG,
  YASM_EXPR_WRT, YASM_EXPR_SEGOFF
}
 Expression operators usable in yasm_expr expressions. More...
 

Functions

YASM_LIB_DECL int yasm__mergesort (void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
 Sort an array using merge sort algorithm. More...
 
YASM_LIB_DECL char * yasm__strsep (char **stringp, const char *delim)
 Separate string by delimiters. More...
 
YASM_LIB_DECL int yasm__strcasecmp (const char *s1, const char *s2)
 Compare two strings, ignoring case differences. More...
 
YASM_LIB_DECL int yasm__strncasecmp (const char *s1, const char *s2, size_t n)
 Compare portion of two strings, ignoring case differences. More...
 
YASM_LIB_DECL char * yasm__xstrdup (const char *str)
 strdup() implementation using yasm_xmalloc(). More...
 
YASM_LIB_DECL char * yasm__xstrndup (const char *str, size_t max)
 strndup() implementation using yasm_xmalloc(). More...
 

Variables

YASM_LIB_DECL void *(* yasm_xmalloc )(size_t size)
 Error-checking memory allocation. More...
 
YASM_LIB_DECL void *(* yasm_xcalloc )(size_t nelem, size_t elsize)
 Error-checking memory allocation (with clear-to-0). More...
 
YASM_LIB_DECL void *(* yasm_xrealloc )(void *oldmem, size_t size)
 Error-checking memory reallocation. More...
 
YASM_LIB_DECL void(* yasm_xfree )(void *p)
 Error-checking memory deallocation. More...
 

Detailed Description

YASM core types and utility functions.

Definition in file coretype.h.

Typedef Documentation

typedef struct yasm_arch yasm_arch

Architecture instance (mostly opaque type).

See Also
arch.h for details.

Definition at line 38 of file coretype.h.

YASM associated data callback structure.

Many data structures can have arbitrary data associated with them.

typedef struct yasm_bytecode yasm_bytecode

Bytecode.

See Also
bytecode.h for details and related functions.

Definition at line 93 of file coretype.h.

typedef struct yasm_dbgfmt yasm_dbgfmt

Debug format interface.

See Also
dbgfmt.h for details.

Definition at line 46 of file coretype.h.

Debug format module interface.

See Also
dbgfmt.h for details.

Definition at line 53 of file coretype.h.

Directive list entry.

See Also
valparam.h for details and related functions.

Definition at line 205 of file coretype.h.

typedef struct yasm_effaddr yasm_effaddr

An effective address.

See Also
insn.h for related functions.

Definition at line 210 of file coretype.h.

typedef struct yasm_errwarns yasm_errwarns

Set of collected error/warnings (opaque type).

See Also
errwarn.h for details.

Definition at line 90 of file coretype.h.

typedef struct yasm_expr yasm_expr

Expression.

See Also
expr.h for details and related functions.

Definition at line 108 of file coretype.h.

typedef enum yasm_expr_op yasm_expr_op

Expression operators usable in yasm_expr expressions.

typedef struct yasm_floatnum yasm_floatnum

Floating point value (opaque type).

See Also
floatnum.h for related functions.

Definition at line 114 of file coretype.h.

typedef struct yasm_insn yasm_insn

An instruction.

See Also
insn.h for related functions.

Definition at line 215 of file coretype.h.

typedef struct yasm_intnum yasm_intnum

Integer value (opaque type).

See Also
intnum.h for related functions.

Definition at line 110 of file coretype.h.

typedef struct yasm_linemap yasm_linemap

Line number mapping repository (opaque type).

See Also
linemap.h for related functions.

Definition at line 192 of file coretype.h.

typedef struct yasm_listfmt yasm_listfmt

List format interface.

See Also
listfmt.h for details.

Definition at line 48 of file coretype.h.

typedef struct yasm_object yasm_object

Object.

See Also
section.h for details and related functions.

Definition at line 96 of file coretype.h.

typedef struct yasm_objfmt yasm_objfmt

Object format interface.

See Also
objfmt.h for details.

Definition at line 44 of file coretype.h.

Object format module interface.

See Also
objfmt.h for details.

Definition at line 51 of file coretype.h.

typedef int(* yasm_output_reloc_func)(yasm_symrec *sym, yasm_bytecode *bc, unsigned char *buf, unsigned int destsize, unsigned int valsize, int warn, void *d)

Convert a symbol reference to its byte representation.

Usually implemented by object formats and debug formats to keep track of relocations generated by themselves.

Parameters
symsymbol
bccurrent bytecode (usually passed into higher-level calling function)
bufbuffer for byte representation
destsizedestination size (in bytes)
valsizesize (in bits)
warnenables standard warnings: zero for none; nonzero for overflow/underflow floating point warnings; negative for signed integer warnings, positive for unsigned integer warnings
dobjfmt-specific data (passed into higher-level calling function)
Returns
Nonzero if an error occurred, 0 otherwise.

Definition at line 296 of file coretype.h.

typedef int(* yasm_output_value_func)(yasm_value *value,unsigned char *buf, unsigned int destsize, unsigned long offset, yasm_bytecode *bc, int warn,void *d)

Convert yasm_value to its byte representation.

Usually implemented by object formats to keep track of relocations and verify legal expressions. Must put the value into the least significant bits of the destination, unless shifted into more significant bits by the shift parameter. The destination bits must be cleared before being set.

Parameters
valuevalue
bufbuffer for byte representation
destsizedestination size (in bytes)
offsetoffset (in bytes) of the expr contents from the start of the bytecode (needed for relative)
bccurrent bytecode (usually passed into higher-level calling function)
warnenables standard warnings: zero for none; nonzero for overflow/underflow floating point warnings
dobjfmt-specific data (passed into higher-level calling function)
Returns
Nonzero if an error occurred, 0 otherwise.

Definition at line 275 of file coretype.h.

typedef struct yasm_parser yasm_parser

Parser instance (mostly opaque type).

See Also
parser.h for details.

Definition at line 42 of file coretype.h.

typedef struct yasm_preproc yasm_preproc

Preprocessor interface.

See Also
preproc.h for details.

Definition at line 40 of file coretype.h.

typedef struct yasm_section yasm_section

Section (opaque type).

See Also
section.h for related functions.

Definition at line 99 of file coretype.h.

typedef struct yasm_stdmac yasm_stdmac

Standard macro structure for modules that allows association of a set of standard macros with a parser/preprocessor combination.

A NULL-terminated array of these structures is used in a number of module interfaces.

typedef struct yasm_symrec yasm_symrec

Symbol record (opaque type).

See Also
symrec.h for related functions.

Definition at line 105 of file coretype.h.

typedef struct yasm_symtab yasm_symtab

Symbol table (opaque type).

See Also
symrec.h for related functions.

Definition at line 102 of file coretype.h.

typedef struct yasm_valparam yasm_valparam

Value/parameter pair (opaque type).

See Also
valparam.h for related functions.

Definition at line 197 of file coretype.h.

List of value/parameters (opaque type).

See Also
valparam.h for related functions.

Definition at line 201 of file coretype.h.

typedef struct yasm_value yasm_value

A value.

May be absolute or relative. Outside the parser, yasm_expr should only be used for absolute exprs. Anything that could contain a relocatable value should use this structure instead.

See Also
value.h for related functions.

Enumeration Type Documentation

Expression operators usable in yasm_expr expressions.

Enumerator
YASM_EXPR_IDENT 

No operation, just a value.

YASM_EXPR_ADD 

Arithmetic addition (+).

YASM_EXPR_SUB 

Arithmetic subtraction (-).

YASM_EXPR_MUL 

Arithmetic multiplication (*).

YASM_EXPR_DIV 

Arithmetic unsigned division.

YASM_EXPR_SIGNDIV 

Arithmetic signed division.

YASM_EXPR_MOD 

Arithmetic unsigned modulus.

YASM_EXPR_SIGNMOD 

Arithmetic signed modulus.

YASM_EXPR_NEG 

Arithmetic negation (-).

YASM_EXPR_NOT 

Bitwise negation.

YASM_EXPR_OR 

Bitwise OR.

YASM_EXPR_AND 

Bitwise AND.

YASM_EXPR_XOR 

Bitwise XOR.

YASM_EXPR_XNOR 

Bitwise XNOR.

YASM_EXPR_NOR 

Bitwise NOR.

YASM_EXPR_SHL 

Shift left (logical).

YASM_EXPR_SHR 

Shift right (logical).

YASM_EXPR_LOGIC 

Start of logic operations (not an op).

YASM_EXPR_LOR 

Logical OR.

YASM_EXPR_LAND 

Logical AND.

YASM_EXPR_LNOT 

Logical negation.

YASM_EXPR_LXOR 

Logical XOR.

YASM_EXPR_LXNOR 

Logical XNOR.

YASM_EXPR_LNOR 

Logical NOR.

YASM_EXPR_LT 

Less than comparison.

YASM_EXPR_GT 

Greater than comparison.

YASM_EXPR_EQ 

Equality comparison.

YASM_EXPR_LE 

Less than or equal to comparison.

YASM_EXPR_GE 

Greater than or equal to comparison.

YASM_EXPR_NE 

Not equal comparison.

YASM_EXPR_NONNUM 

Start of non-numeric operations (not an op).

YASM_EXPR_SEG 

SEG operator (gets segment portion of address).

YASM_EXPR_WRT 

WRT operator (gets offset of address relative to some other segment).

YASM_EXPR_SEGOFF 

The ':' in segment:offset.

Definition at line 218 of file coretype.h.

Function Documentation

YASM_LIB_DECL int yasm__mergesort ( void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

Sort an array using merge sort algorithm.

Parameters
basebase of array
nmembnumber of elements in array
sizesize of each array element
comparelement comparison function
YASM_LIB_DECL int yasm__strcasecmp ( const char *  s1,
const char *  s2 
)

Compare two strings, ignoring case differences.

Parameters
s1string 1
s2string 2
Returns
0 if strings are equal, -1 if s1<s2, 1 if s1>s2.
YASM_LIB_DECL int yasm__strncasecmp ( const char *  s1,
const char *  s2,
size_t  n 
)

Compare portion of two strings, ignoring case differences.

Parameters
s1string 1
s2string 2
nmaximum number of characters to compare
Returns
0 if strings are equal, -1 if s1<s2, 1 if s1>s2.
YASM_LIB_DECL char* yasm__strsep ( char **  stringp,
const char *  delim 
)

Separate string by delimiters.

Parameters
stringpstring
delimset of 1 or more delimiters
Returns
First/next substring.
YASM_LIB_DECL char* yasm__xstrdup ( const char *  str)

strdup() implementation using yasm_xmalloc().

Parameters
strstring
Returns
Newly allocated duplicate string.
YASM_LIB_DECL char* yasm__xstrndup ( const char *  str,
size_t  max 
)

strndup() implementation using yasm_xmalloc().

Parameters
strstring
maxmaximum number of characters to copy
Returns
Newly allocated duplicate string.

Variable Documentation

YASM_LIB_DECL void*(* yasm_xcalloc)(size_t nelem, size_t elsize)

Error-checking memory allocation (with clear-to-0).

A default implementation is provided that calls yasm_fatal() on allocation errors. A replacement should never return NULL.

Parameters
sizenumber of elements to allocate
elsizesize (in bytes) of each element
Returns
Allocated and cleared memory block.
YASM_LIB_DECL void(* yasm_xfree)(void *p)

Error-checking memory deallocation.

A default implementation is provided that calls yasm_fatal() on allocation errors.

Parameters
pmemory block to free
YASM_LIB_DECL void*(* yasm_xmalloc)(size_t size)

Error-checking memory allocation.

A default implementation is provided that calls yasm_fatal() on allocation errors. A replacement should never return NULL.

Parameters
sizenumber of bytes to allocate
Returns
Allocated memory block.
YASM_LIB_DECL void*(* yasm_xrealloc)(void *oldmem, size_t size)

Error-checking memory reallocation.

A default implementation is provided that calls yasm_fatal() on allocation errors. A replacement should never return NULL.

Parameters
oldmemmemory block to resize
elsizenew size, in bytes
Returns
Re-allocated memory block.