libyasm
|
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... | |
Typedefs | |
typedef enum yasm_arch_create_error | yasm_arch_create_error |
Errors that may be returned by yasm_arch_module::create(). More... | |
typedef enum yasm_arch_insnprefix | yasm_arch_insnprefix |
Return values for yasm_arch_module::parse_check_insnprefix(). More... | |
typedef enum yasm_arch_regtmod | yasm_arch_regtmod |
Types of registers / target modifiers that may be returned by yasm_arch_module::parse_check_regtmod(). | |
typedef struct yasm_arch_machine | yasm_arch_machine |
YASM machine subtype. More... | |
typedef struct yasm_arch_module | 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. More... | |
const char * | yasm_arch_keyword (const yasm_arch *arch) |
Get the keyword used to select an architecture. More... | |
unsigned int | yasm_arch_wordsize (const yasm_arch *arch) |
Get the word size of an architecture. More... | |
unsigned int | yasm_arch_min_insn_len (const yasm_arch *arch) |
Get the minimum instruction length of an architecture. More... | |
yasm_arch * | yasm_arch_create (const yasm_arch_module *module, const char *machine, const char *parser, yasm_arch_create_error *error) |
Create architecture. More... | |
void | yasm_arch_destroy (yasm_arch *arch) |
Clean up, free any architecture-allocated memory. More... | |
const char * | yasm_arch_get_machine (const yasm_arch *arch) |
Get architecture's active machine name. More... | |
unsigned int | yasm_arch_get_address_size (const yasm_arch *arch) |
Get architecture's active address size, in bits. More... | |
int | yasm_arch_set_var (yasm_arch *arch, const char *var, unsigned long val) |
Set any arch-specific variables. More... | |
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. More... | |
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. More... | |
const unsigned char ** | yasm_arch_get_fill (const yasm_arch *arch) |
Get NOP fill patterns for 1-15 bytes of fill. More... | |
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. More... | |
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. More... | |
unsigned int | yasm_arch_get_reg_size (yasm_arch *arch, uintptr_t reg) |
Get the equivalent size of a register in bits. More... | |
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. More... | |
void | yasm_arch_reg_print (yasm_arch *arch, uintptr_t reg, FILE *f) |
Print a register. More... | |
void | yasm_arch_segreg_print (yasm_arch *arch, uintptr_t segreg, FILE *f) |
Print a segment register. More... | |
yasm_effaddr * | yasm_arch_ea_create (yasm_arch *arch, yasm_expr *e) |
Create an effective address from an expression. More... | |
void | yasm_arch_ea_destroy (yasm_arch *arch, yasm_effaddr *ea) |
Delete (free allocated memory for) an effective address. More... | |
void | yasm_arch_ea_print (const yasm_arch *arch, const yasm_effaddr *ea, FILE *f, int indent_level) |
Print an effective address. More... | |
yasm_bytecode * | yasm_arch_create_empty_insn (yasm_arch *arch, unsigned long line) |
Create a bytecode that represents a single empty (0 length) instruction. More... | |
YASM architecture interface.
Definition in file arch.h.
typedef enum yasm_arch_create_error yasm_arch_create_error |
Errors that may be returned by yasm_arch_module::create().
typedef enum yasm_arch_insnprefix yasm_arch_insnprefix |
Return values for yasm_arch_module::parse_check_insnprefix().
typedef struct yasm_arch_machine yasm_arch_machine |
YASM machine subtype.
A number of different machine types may be associated with a single architecture. These may be specific CPU's, but the ABI used to interface with the architecture should be the primary differentiator between machines. Some object formats (ELF) use the machine to determine parameters within the generated output.
typedef struct yasm_arch_module yasm_arch_module |
YASM architecture module interface.
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. |
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. |
enum yasm_arch_regtmod |
Types of registers / target modifiers that may be returned by yasm_arch_module::parse_check_regtmod().
yasm_arch* yasm_arch_create | ( | const yasm_arch_module * | module, |
const char * | machine, | ||
const char * | parser, | ||
yasm_arch_create_error * | error | ||
) |
Create architecture.
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 |
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.
arch | architecture |
line | virtual line (from yasm_linemap) |
void yasm_arch_destroy | ( | yasm_arch * | arch | ) |
Clean up, free any architecture-allocated memory.
arch | architecture |
yasm_effaddr* yasm_arch_ea_create | ( | yasm_arch * | arch, |
yasm_expr * | e | ||
) |
Create an effective address from an expression.
arch | architecture |
e | expression (kept, do not delete) |
void yasm_arch_ea_destroy | ( | yasm_arch * | arch, |
yasm_effaddr * | ea | ||
) |
Delete (free allocated memory for) an effective address.
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.
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.
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 |
unsigned int yasm_arch_get_address_size | ( | const yasm_arch * | arch | ) |
Get architecture's active address size, in bits.
arch | architecture |
const unsigned char** yasm_arch_get_fill | ( | const yasm_arch * | arch | ) |
Get NOP fill patterns for 1-15 bytes of fill.
arch | architecture |
const char* yasm_arch_get_machine | ( | const yasm_arch * | arch | ) |
Get architecture's active machine name.
arch | architecture |
unsigned int yasm_arch_get_reg_size | ( | yasm_arch * | arch, |
uintptr_t | reg | ||
) |
Get the equivalent size of a register in bits.
arch | architecture |
reg | register |
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.
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) |
const char* yasm_arch_keyword | ( | const yasm_arch * | arch | ) |
Get the keyword used to select an architecture.
arch | architecture |
unsigned int yasm_arch_min_insn_len | ( | const yasm_arch * | arch | ) |
Get the minimum instruction length of an architecture.
arch | architecture |
const char* yasm_arch_name | ( | const yasm_arch * | arch | ) |
Get the one-line description of an architecture.
arch | 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.
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) |
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.
arch | architecture |
id | identifier as in the input file |
id_len | length of id string |
data | extra identification information (yasm_arch-specific) [output] |
void yasm_arch_reg_print | ( | yasm_arch * | arch, |
uintptr_t | reg, | ||
FILE * | f | ||
) |
Print a register.
For debugging purposes.
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.
arch | architecture |
reggroup | register group |
regindex | register index |
void yasm_arch_segreg_print | ( | yasm_arch * | arch, |
uintptr_t | segreg, | ||
FILE * | f | ||
) |
Print a segment register.
For debugging purposes.
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.
arch | architecture |
var | variable name |
val | value to set |
unsigned int yasm_arch_wordsize | ( | const yasm_arch * | arch | ) |
Get the word size of an architecture.
arch | architecture |