libyasm/value.h File Reference

YASM value interface. More...

Go to the source code of this file.

Functions

YASM_LIB_DECL void yasm_value_initialize (yasm_value *value, yasm_expr *e, unsigned int size)
 Initialize a yasm_value with just an expression.
YASM_LIB_DECL void yasm_value_init_sym (yasm_value *value, yasm_symrec *sym, unsigned int size)
 Initialize a yasm_value with just a symrec.
YASM_LIB_DECL void yasm_value_init_copy (yasm_value *value, const yasm_value *orig)
 Initialize a yasm_value as a copy of another yasm_value.
YASM_LIB_DECL void yasm_value_delete (yasm_value *value)
 Frees any memory inside value; does not free value itself.
YASM_LIB_DECL void yasm_value_set_curpos_rel (yasm_value *value, yasm_bytecode *bc, unsigned int ip_rel)
 Set a value to be relative to the current assembly position rather than relative to the section start.
YASM_LIB_DECL int yasm_value_finalize (yasm_value *value, yasm_bytecode *precbc)
 Perform yasm_value_finalize_expr() on a value that already exists from being initialized with yasm_value_initialize().
YASM_LIB_DECL int yasm_value_finalize_expr (yasm_value *value, yasm_expr *e, yasm_bytecode *precbc, unsigned int size)
 Break a yasm_expr into a yasm_value constituent parts.
YASM_LIB_DECL yasm_intnumyasm_value_get_intnum (yasm_value *value, yasm_bytecode *bc, int calc_bc_dist)
 Get value if absolute or PC-relative section-local relative.
YASM_LIB_DECL int yasm_value_output_basic (yasm_value *value, unsigned char *buf, size_t destsize, yasm_bytecode *bc, int warn, yasm_arch *arch)
 Output value if constant or PC-relative section-local.
YASM_LIB_DECL void yasm_value_print (const yasm_value *value, FILE *f, int indent_level)
 Print a value.


Detailed Description

YASM value interface.

Definition in file value.h.


Function Documentation

YASM_LIB_DECL void yasm_value_delete ( yasm_value value  ) 

Frees any memory inside value; does not free value itself.

Parameters:
value value

YASM_LIB_DECL int yasm_value_finalize ( yasm_value value,
yasm_bytecode precbc 
)

Perform yasm_value_finalize_expr() on a value that already exists from being initialized with yasm_value_initialize().

Parameters:
value value
precbc previous bytecode to bytecode containing value
Returns:
Nonzero if value could not be split.

YASM_LIB_DECL int yasm_value_finalize_expr ( yasm_value value,
yasm_expr e,
yasm_bytecode precbc,
unsigned int  size 
)

Break a yasm_expr into a yasm_value constituent parts.

Extracts the relative portion of the value, SEG and WRT portions, and top-level right shift, if any. Places the remaining expr into the absolute portion of the value. Essentially a combination of yasm_value_initialize() and yasm_value_finalize(). First expands references to symrecs in absolute sections by expanding with the absolute section start plus the symrec offset within the absolute section.

Parameters:
value value to store split portions into
e expression input
precbc previous bytecode to bytecode containing expression
size value size (in bits)
Returns:
Nonzero if the expr could not be split into a value for some reason (e.g. the relative portion was not added, but multiplied, etc).
Warning:
Do not use e after this call. Even if an error is returned, e is stored into value.
Note:
This should only be called after the parse is complete. Calling before the parse is complete will usually result in an error return.

YASM_LIB_DECL yasm_intnum* yasm_value_get_intnum ( yasm_value value,
yasm_bytecode bc,
int  calc_bc_dist 
)

Get value if absolute or PC-relative section-local relative.

Returns NULL otherwise.

Parameters:
value value
bc current bytecode (for PC-relative calculation); if NULL, NULL is returned for PC-relative values.
calc_bc_dist if nonzero, calculates bytecode distances in absolute portion of value
Note:
Adds in value.rel (correctly) if PC-relative and in the same section as bc (and there is no WRT or SEG).
Returns:
Intnum if can be resolved to integer value, otherwise NULL.

YASM_LIB_DECL void yasm_value_init_copy ( yasm_value value,
const yasm_value orig 
)

Initialize a yasm_value as a copy of another yasm_value.

Any expressions within orig are copied, so it's safe to delete the copy.

Parameters:
value value (copy to create)
orig original value

YASM_LIB_DECL void yasm_value_init_sym ( yasm_value value,
yasm_symrec sym,
unsigned int  size 
)

Initialize a yasm_value with just a symrec.

No processing is performed, the symrec is simply stuck into value.rel and the other fields are initialized.

Parameters:
value value to be initialized
sym symrec
size value size (in bits)

YASM_LIB_DECL void yasm_value_initialize ( yasm_value value,
yasm_expr e,
unsigned int  size 
)

Initialize a yasm_value with just an expression.

No processing is performed, the expression is simply stuck into value.abs and the other fields are initialized. Use yasm_expr_extract_value() to perform "smart" processing into a yasm_value. This function is intended for use during parsing simply to ensure all fields of the value are initialized; after the parse is complete, yasm_value_extract() should be called to finalize the value. The value defaults to unsigned.

Parameters:
value value to be initialized
e expression (kept)
size value size (in bits)

YASM_LIB_DECL int yasm_value_output_basic ( yasm_value value,
unsigned char *  buf,
size_t  destsize,
yasm_bytecode bc,
int  warn,
yasm_arch arch 
)

Output value if constant or PC-relative section-local.

This should be used from objfmt yasm_output_value_func() functions. functions.

Parameters:
value value
buf buffer for byte representation
destsize destination size (in bytes)
bc current bytecode (usually passed into higher-level calling function)
warn enables standard warnings: zero for none; nonzero for overflow/underflow floating point and integer warnings
arch architecture
Note:
Adds in value.rel (correctly) if PC-relative and in the same section as bc (and there is no WRT or SEG); if this is not the desired behavior, e.g. a reloc is needed in this case, don't use this function!
Returns:
0 if no value output due to value needing relocation; 1 if value output; -1 if error.

YASM_LIB_DECL void yasm_value_print ( const yasm_value value,
FILE *  f,
int  indent_level 
)

Print a value.

For debugging purposes.

Parameters:
value value
indent_level indentation level
f file

YASM_LIB_DECL void yasm_value_set_curpos_rel ( yasm_value value,
yasm_bytecode bc,
unsigned int  ip_rel 
)

Set a value to be relative to the current assembly position rather than relative to the section start.

Parameters:
value value
bc bytecode containing value
ip_rel if nonzero, indicates IP-relative data relocation, sometimes used to generate special relocations
Note:
If value is just an absolute value, will get an absolute symrec to reference to (via bc's symbol table).


Generated on Thu Jul 24 01:23:32 2008 for libyasm by  doxygen 1.5.2