libyasm/arch.h File Reference

YASM architecture interface. More...

Go to the source code of this file.

Data Structures

struct  yasm_arch_machine
 YASM machine subtype. More...
struct  yasm_arch_module
 YASM architecture module interface. More...

Enumerations

enum  yasm_arch_create_error { YASM_ARCH_CREATE_OK = 0, YASM_ARCH_CREATE_BAD_MACHINE, YASM_ARCH_CREATE_BAD_PARSER }
 Errors that may be returned by yasm_arch_module::create(). More...
enum  yasm_arch_insnprefix { YASM_ARCH_NOTINSNPREFIX = 0, YASM_ARCH_INSN, YASM_ARCH_PREFIX }
 Return values for yasm_arch_module::parse_check_insnprefix(). More...
enum  yasm_arch_regtmod {
  YASM_ARCH_NOTREGTMOD = 0, YASM_ARCH_REG, YASM_ARCH_REGGROUP, YASM_ARCH_SEGREG,
  YASM_ARCH_TARGETMOD
}
 Types of registers / target modifiers that may be returned by yasm_arch_module::parse_check_regtmod(). More...

Functions

const char * yasm_arch_name (const yasm_arch *arch)
 Get the one-line description of an architecture.
const char * yasm_arch_keyword (const yasm_arch *arch)
 Get the keyword used to select an architecture.
unsigned int yasm_arch_wordsize (const yasm_arch *arch)
 Get the word size of an architecture.
unsigned int yasm_arch_min_insn_len (const yasm_arch *arch)
 Get the minimum instruction length of an architecture.
yasm_archyasm_arch_create (const yasm_arch_module *module, const char *machine, const char *parser, yasm_arch_create_error *error)
 Create architecture.
void yasm_arch_destroy (yasm_arch *arch)
 Clean up, free any architecture-allocated memory.
const char * yasm_arch_get_machine (const yasm_arch *arch)
 Get architecture's active machine name.
unsigned int yasm_arch_get_address_size (const yasm_arch *arch)
 Get architecture's active address size, in bits.
int yasm_arch_set_var (yasm_arch *arch, const char *var, unsigned long val)
 Set any arch-specific variables.
yasm_arch_insnprefix yasm_arch_parse_check_insnprefix (yasm_arch *arch, const char *id, size_t id_len, unsigned long line, yasm_bytecode **bc, uintptr_t *prefix)
 Check an generic identifier to see if it matches architecture specific names for instructions or instruction prefixes.
yasm_arch_regtmod yasm_arch_parse_check_regtmod (yasm_arch *arch, const char *id, size_t id_len, uintptr_t *data)
 Check an generic identifier to see if it matches architecture specific names for registers or target modifiers.
const unsigned char ** yasm_arch_get_fill (const yasm_arch *arch)
 Get NOP fill patterns for 1-15 bytes of fill.
int yasm_arch_floatnum_tobytes (yasm_arch *arch, const yasm_floatnum *flt, unsigned char *buf, size_t destsize, size_t valsize, size_t shift, int warn)
 Output yasm_floatnum to buffer.
int yasm_arch_intnum_tobytes (yasm_arch *arch, const yasm_intnum *intn, unsigned char *buf, size_t destsize, size_t valsize, int shift, const yasm_bytecode *bc, int warn)
 Output yasm_intnum to buffer.
unsigned int yasm_arch_get_reg_size (yasm_arch *arch, uintptr_t reg)
 Get the equivalent size of a register in bits.
uintptr_t yasm_arch_reggroup_get_reg (yasm_arch *arch, uintptr_t reggroup, unsigned long regindex)
 Get a specific register of a register group, based on the register group and the index within the group.
void yasm_arch_reg_print (yasm_arch *arch, uintptr_t reg, FILE *f)
 Print a register.
void yasm_arch_segreg_print (yasm_arch *arch, uintptr_t segreg, FILE *f)
 Print a segment register.
yasm_effaddryasm_arch_ea_create (yasm_arch *arch, yasm_expr *e)
 Create an effective address from an expression.
void yasm_arch_ea_destroy (yasm_arch *arch, yasm_effaddr *ea)
 Delete (free allocated memory for) an effective address.
void yasm_arch_ea_print (const yasm_arch *arch, const yasm_effaddr *ea, FILE *f, int indent_level)
 Print an effective address.
yasm_bytecodeyasm_arch_create_empty_insn (yasm_arch *arch, unsigned long line)
 Create a bytecode that represents a single empty (0 length) instruction.


Detailed Description

YASM architecture interface.

Definition in file arch.h.


Enumeration Type Documentation

enum yasm_arch_create_error

Errors that may be returned by yasm_arch_module::create().

Enumerator:
YASM_ARCH_CREATE_OK  No error.

YASM_ARCH_CREATE_BAD_MACHINE  Unrecognized machine name.

YASM_ARCH_CREATE_BAD_PARSER  Unrecognized parser name.

Definition at line 38 of file arch.h.

enum yasm_arch_insnprefix

Return values for yasm_arch_module::parse_check_insnprefix().

Enumerator:
YASM_ARCH_NOTINSNPREFIX  Unrecognized.
YASM_ARCH_INSN  An instruction.
YASM_ARCH_PREFIX  An instruction prefix.

Definition at line 45 of file arch.h.

enum yasm_arch_regtmod

Types of registers / target modifiers that may be returned by yasm_arch_module::parse_check_regtmod().

Enumerator:
YASM_ARCH_NOTREGTMOD  Unrecognized.
YASM_ARCH_REG  A "normal" register.
YASM_ARCH_REGGROUP  A group of indexable registers.
YASM_ARCH_SEGREG  A segment register.
YASM_ARCH_TARGETMOD  A target modifier (for jumps).

Definition at line 54 of file arch.h.


Function Documentation

yasm_arch* yasm_arch_create ( const yasm_arch_module module,
const char *  machine,
const char *  parser,
yasm_arch_create_error error 
)

Create architecture.

Parameters:
module architecture module
machine keyword of machine in use (must be one listed in yasm_arch_module.machines)
parser keyword of parser in use
error error return value
Returns:
NULL on error (error returned in error parameter), otherwise new architecture.

yasm_bytecode* yasm_arch_create_empty_insn ( yasm_arch arch,
unsigned long  line 
)

Create a bytecode that represents a single empty (0 length) instruction.

This is used for handling solitary prefixes.

Parameters:
arch architecture
line virtual line (from yasm_linemap)
Returns:
Newly allocated bytecode.

void yasm_arch_destroy ( yasm_arch arch  ) 

Clean up, free any architecture-allocated memory.

Parameters:
arch architecture

yasm_effaddr* yasm_arch_ea_create ( yasm_arch arch,
yasm_expr e 
)

Create an effective address from an expression.

Parameters:
arch architecture
e expression (kept, do not delete)
Returns:
Newly allocated effective address.

void yasm_arch_ea_destroy ( yasm_arch arch,
yasm_effaddr ea 
)

Delete (free allocated memory for) an effective address.

Parameters:
arch architecture
ea effective address (only pointer to it).

void yasm_arch_ea_print ( const yasm_arch arch,
const yasm_effaddr ea,
FILE *  f,
int  indent_level 
)

Print an effective address.

For debugging purposes.

Parameters:
arch architecture
ea effective address
f file
indent_level indentation level

int yasm_arch_floatnum_tobytes ( yasm_arch arch,
const yasm_floatnum flt,
unsigned char *  buf,
size_t  destsize,
size_t  valsize,
size_t  shift,
int  warn 
)

Output yasm_floatnum to buffer.

Puts the value into the least significant bits of the destination, or may be shifted into more significant bits by the shift parameter. The destination bits are cleared before being set. Architecture-specific because of endianness.

Parameters:
arch architecture
flt floating point value
buf buffer to write into
destsize destination size (in bytes)
valsize size (in bits)
shift left shift (in bits)
warn enables standard overflow/underflow warnings
Returns:
Nonzero on error.

unsigned int yasm_arch_get_address_size ( const yasm_arch arch  ) 

Get architecture's active address size, in bits.

Parameters:
arch architecture
Returns:
Active address size (in bits).

const unsigned char** yasm_arch_get_fill ( const yasm_arch arch  ) 

Get NOP fill patterns for 1-15 bytes of fill.

Parameters:
arch architecture
Returns:
16-entry array of arrays; [0] is unused, [1] - [15] point to arrays of 1-15 bytes (respectively) in length.

const char* yasm_arch_get_machine ( const yasm_arch arch  ) 

Get architecture's active machine name.

Parameters:
arch architecture
Returns:
Active machine name.

unsigned int yasm_arch_get_reg_size ( yasm_arch arch,
uintptr_t  reg 
)

Get the equivalent size of a register in bits.

Parameters:
arch architecture
reg register
Returns:
0 if there is no suitable equivalent size, otherwise the size.

int yasm_arch_intnum_tobytes ( yasm_arch arch,
const yasm_intnum intn,
unsigned char *  buf,
size_t  destsize,
size_t  valsize,
int  shift,
const yasm_bytecode bc,
int  warn 
)

Output yasm_intnum to buffer.

Puts the value into the least significant bits of the destination, or may be shifted into more significant bits by the shift parameter. The destination bits are cleared before being set.

Parameters:
arch architecture
intn integer value
buf buffer to write into
destsize destination size (in bytes)
valsize size (in bits)
shift left shift (in bits); may be negative to specify right shift (standard warnings include truncation to boundary)
bc bytecode being output ("parent" of value)
warn enables standard warnings (value doesn't fit into valsize bits)
Returns:
Nonzero on error.

const char* yasm_arch_keyword ( const yasm_arch arch  ) 

Get the keyword used to select an architecture.

Parameters:
arch architecture
Returns:
Architecture keyword.

unsigned int yasm_arch_min_insn_len ( const yasm_arch arch  ) 

Get the minimum instruction length of an architecture.

Parameters:
arch architecture
Returns:
Minimum instruction length (in bytes).

const char* yasm_arch_name ( const yasm_arch arch  ) 

Get the one-line description of an architecture.

Parameters:
arch architecture
Returns:
One-line description of architecture.

yasm_arch_insnprefix yasm_arch_parse_check_insnprefix ( yasm_arch arch,
const char *  id,
size_t  id_len,
unsigned long  line,
yasm_bytecode **  bc,
uintptr_t *  prefix 
)

Check an generic identifier to see if it matches architecture specific names for instructions or instruction prefixes.

Unrecognized identifiers should return YASM_ARCH_NOTINSNPREFIX so they can be treated as normal symbols. Any additional data beyond just the type (almost always necessary) should be returned into the space provided by the data parameter.

Parameters:
arch architecture
id identifier as in the input file
id_len length of id string
line virtual line
bc for instructions, yasm_insn-based bytecode is returned (and NULL otherwise)
prefix for prefixes, yasm_arch-specific value is returned (and 0 otherwise)
Returns:
Identifier type (YASM_ARCH_NOTINSNPREFIX if unrecognized)

yasm_arch_regtmod yasm_arch_parse_check_regtmod ( yasm_arch arch,
const char *  id,
size_t  id_len,
uintptr_t *  data 
)

Check an generic identifier to see if it matches architecture specific names for registers or target modifiers.

Unrecognized identifiers should return YASM_ARCH_NOTREGTMOD. Any additional data beyond just the type (almost always necessary) should be returned into the space provided by the data parameter.

Parameters:
arch architecture
id identifier as in the input file
id_len length of id string
data extra identification information (yasm_arch-specific) [output]
Returns:
Identifier type (YASM_ARCH_NOTREGTMOD if unrecognized)

void yasm_arch_reg_print ( yasm_arch arch,
uintptr_t  reg,
FILE *  f 
)

Print a register.

For debugging purposes.

Parameters:
arch architecture
reg register
f file

uintptr_t yasm_arch_reggroup_get_reg ( yasm_arch arch,
uintptr_t  reggroup,
unsigned long  regindex 
)

Get a specific register of a register group, based on the register group and the index within the group.

Parameters:
arch architecture
reggroup register group
regindex register index
Returns:
0 if regindex is not valid for that register group, otherwise the specific register value.

void yasm_arch_segreg_print ( yasm_arch arch,
uintptr_t  segreg,
FILE *  f 
)

Print a segment register.

For debugging purposes.

Parameters:
arch architecture
segreg segment register
f file

int yasm_arch_set_var ( yasm_arch arch,
const char *  var,
unsigned long  val 
)

Set any arch-specific variables.

For example, "mode_bits" in x86.

Parameters:
arch architecture
var variable name
val value to set
Returns:
Zero on success, non-zero on failure (variable does not exist).

unsigned int yasm_arch_wordsize ( const yasm_arch arch  ) 

Get the word size of an architecture.

Parameters:
arch architecture
Returns:
Word size (in bits).


Generated on Fri Jul 25 01:23:32 2008 for libyasm by  doxygen 1.5.2