libyasm
|
YASM integer number interface. More...
Go to the source code of this file.
Functions | |
YASM_LIB_DECL void | yasm_intnum_initialize (void) |
Initialize intnum internal data structures. More... | |
YASM_LIB_DECL void | yasm_intnum_cleanup (void) |
Clean up internal intnum allocations. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_dec (char *str) |
Create a new intnum from a decimal string. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_bin (char *str) |
Create a new intnum from a binary string. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_oct (char *str) |
Create a new intnum from an octal string. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_hex (char *str) |
Create a new intnum from a hexidecimal string. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_charconst_nasm (const char *str) |
Convert character constant to integer value, using NASM rules. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_charconst_tasm (const char *str) |
Convert character constant to integer value, using TASM rules. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_uint (unsigned long i) |
Create a new intnum from an unsigned integer value. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_int (long i) |
Create a new intnum from an signed integer value. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_leb128 (const unsigned char *ptr, int sign, unsigned long *size) |
Create a new intnum from LEB128-encoded form. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_create_sized (unsigned char *ptr, int sign, size_t srcsize, int bigendian) |
Create a new intnum from a little-endian or big-endian buffer. More... | |
YASM_LIB_DECL yasm_intnum * | yasm_intnum_copy (const yasm_intnum *intn) |
Duplicate an intnum. More... | |
YASM_LIB_DECL void | yasm_intnum_destroy (yasm_intnum *intn) |
Destroy (free allocated memory for) an intnum. More... | |
YASM_LIB_DECL int | yasm_intnum_calc (yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand) |
Floating point calculation function: acc = acc op operand. More... | |
YASM_LIB_DECL int | yasm_intnum_compare (const yasm_intnum *intn1, const yasm_intnum *intn2) |
Compare two intnums. More... | |
YASM_LIB_DECL void | yasm_intnum_zero (yasm_intnum *intn) |
Zero an intnum. More... | |
YASM_LIB_DECL void | yasm_intnum_set (yasm_intnum *intn, const yasm_intnum *val) |
Set an intnum to the value of another intnum. More... | |
YASM_LIB_DECL void | yasm_intnum_set_uint (yasm_intnum *intn, unsigned long val) |
Set an intnum to an unsigned integer. More... | |
YASM_LIB_DECL void | yasm_intnum_set_int (yasm_intnum *intn, long val) |
Set an intnum to an signed integer. More... | |
YASM_LIB_DECL int | yasm_intnum_is_zero (const yasm_intnum *acc) |
Simple value check for 0. More... | |
YASM_LIB_DECL int | yasm_intnum_is_pos1 (const yasm_intnum *acc) |
Simple value check for 1. More... | |
YASM_LIB_DECL int | yasm_intnum_is_neg1 (const yasm_intnum *acc) |
Simple value check for -1. More... | |
YASM_LIB_DECL int | yasm_intnum_sign (const yasm_intnum *acc) |
Simple sign check. More... | |
YASM_LIB_DECL unsigned long | yasm_intnum_get_uint (const yasm_intnum *intn) |
Convert an intnum to an unsigned 32-bit value. More... | |
YASM_LIB_DECL long | yasm_intnum_get_int (const yasm_intnum *intn) |
Convert an intnum to a signed 32-bit value. More... | |
YASM_LIB_DECL void | yasm_intnum_get_sized (const yasm_intnum *intn, unsigned char *ptr, size_t destsize, size_t valsize, int shift, int bigendian, int warn) |
Output yasm_intnum to buffer in little-endian or big-endian. More... | |
YASM_LIB_DECL int | yasm_intnum_check_size (const yasm_intnum *intn, size_t size, size_t rshift, int rangetype) |
Check to see if intnum will fit without overflow into size bits. More... | |
YASM_LIB_DECL int | yasm_intnum_in_range (const yasm_intnum *intn, long low, long high) |
Check to see if intnum will fit into a particular numeric range. More... | |
YASM_LIB_DECL unsigned long | yasm_intnum_get_leb128 (const yasm_intnum *intn, unsigned char *ptr, int sign) |
Output yasm_intnum to buffer in LEB128-encoded form. More... | |
YASM_LIB_DECL unsigned long | yasm_intnum_size_leb128 (const yasm_intnum *intn, int sign) |
Calculate number of bytes LEB128-encoded form of yasm_intnum will take. More... | |
YASM_LIB_DECL unsigned long | yasm_get_sleb128 (long v, unsigned char *ptr) |
Output integer to buffer in signed LEB128-encoded form. More... | |
YASM_LIB_DECL unsigned long | yasm_size_sleb128 (long v) |
Calculate number of bytes signed LEB128-encoded form of integer will take. More... | |
YASM_LIB_DECL unsigned long | yasm_get_uleb128 (unsigned long v, unsigned char *ptr) |
Output integer to buffer in unsigned LEB128-encoded form. More... | |
YASM_LIB_DECL unsigned long | yasm_size_uleb128 (unsigned long v) |
Calculate number of bytes unsigned LEB128-encoded form of integer will take. More... | |
YASM_LIB_DECL char * | yasm_intnum_get_str (const yasm_intnum *intn) |
Get an intnum as a signed decimal string. More... | |
YASM_LIB_DECL void | yasm_intnum_print (const yasm_intnum *intn, FILE *f) |
Print an intnum. More... | |
YASM integer number interface.
Definition in file intnum.h.
YASM_LIB_DECL unsigned long yasm_get_sleb128 | ( | long | v, |
unsigned char * | ptr | ||
) |
Output integer to buffer in signed LEB128-encoded form.
v | integer |
ptr | pointer to storage for output bytes |
YASM_LIB_DECL unsigned long yasm_get_uleb128 | ( | unsigned long | v, |
unsigned char * | ptr | ||
) |
Output integer to buffer in unsigned LEB128-encoded form.
v | integer |
ptr | pointer to storage for output bytes |
YASM_LIB_DECL int yasm_intnum_calc | ( | yasm_intnum * | acc, |
yasm_expr_op | op, | ||
yasm_intnum * | operand | ||
) |
Floating point calculation function: acc = acc op operand.
acc | intnum accumulator |
op | operation |
operand | intnum operand |
YASM_LIB_DECL int yasm_intnum_check_size | ( | const yasm_intnum * | intn, |
size_t | size, | ||
size_t | rshift, | ||
int | rangetype | ||
) |
Check to see if intnum will fit without overflow into size bits.
intn | intnum |
size | number of bits of output space |
rshift | right shift |
rangetype | signed/unsigned range selection: 0 => (0, unsigned max); 1 => (signed min, signed max); 2 => (signed min, unsigned max) |
YASM_LIB_DECL void yasm_intnum_cleanup | ( | void | ) |
Clean up internal intnum allocations.
YASM_LIB_DECL int yasm_intnum_compare | ( | const yasm_intnum * | intn1, |
const yasm_intnum * | intn2 | ||
) |
Compare two intnums.
intn1 | first intnum |
intn2 | second intnum |
YASM_LIB_DECL yasm_intnum* yasm_intnum_copy | ( | const yasm_intnum * | intn | ) |
Duplicate an intnum.
intn | intnum |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_bin | ( | char * | str | ) |
Create a new intnum from a binary string.
str | binary string |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_charconst_nasm | ( | const char * | str | ) |
Convert character constant to integer value, using NASM rules.
NASM syntax supports automatic conversion from strings such as 'abcd' to a 32-bit integer value (little endian order). This function performs those conversions.
str | character constant string |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_charconst_tasm | ( | const char * | str | ) |
Convert character constant to integer value, using TASM rules.
TASM syntax supports automatic conversion from strings such as 'abcd' to a 32-bit integer value (big endian order). This function performs those conversions.
str | character constant string |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_dec | ( | char * | str | ) |
Create a new intnum from a decimal string.
str | decimal string |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_hex | ( | char * | str | ) |
Create a new intnum from a hexidecimal string.
str | hexidecimal string |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_int | ( | long | i | ) |
Create a new intnum from an signed integer value.
i | signed integer value |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_leb128 | ( | const unsigned char * | ptr, |
int | sign, | ||
unsigned long * | size | ||
) |
Create a new intnum from LEB128-encoded form.
ptr | pointer to start of LEB128 encoded form |
sign | signed (1) or unsigned (0) LEB128 format |
size | number of bytes read from ptr (output) |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_oct | ( | char * | str | ) |
Create a new intnum from an octal string.
str | octal string |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_sized | ( | unsigned char * | ptr, |
int | sign, | ||
size_t | srcsize, | ||
int | bigendian | ||
) |
Create a new intnum from a little-endian or big-endian buffer.
In little endian, the LSB is in ptr[0].
ptr | pointer to start of buffer |
sign | signed (1) or unsigned (0) source |
srcsize | source buffer size (in bytes) |
bigendian | endianness (nonzero=big, zero=little) |
YASM_LIB_DECL yasm_intnum* yasm_intnum_create_uint | ( | unsigned long | i | ) |
Create a new intnum from an unsigned integer value.
i | unsigned integer value |
YASM_LIB_DECL void yasm_intnum_destroy | ( | yasm_intnum * | intn | ) |
Destroy (free allocated memory for) an intnum.
intn | intnum |
YASM_LIB_DECL long yasm_intnum_get_int | ( | const yasm_intnum * | intn | ) |
Convert an intnum to a signed 32-bit value.
The value is in "standard" C format (eg, of unknown endian).
intn | intnum |
YASM_LIB_DECL unsigned long yasm_intnum_get_leb128 | ( | const yasm_intnum * | intn, |
unsigned char * | ptr, | ||
int | sign | ||
) |
Output yasm_intnum to buffer in LEB128-encoded form.
intn | intnum |
ptr | pointer to storage for output bytes |
sign | signedness of LEB128 encoding (0=unsigned, 1=signed) |
YASM_LIB_DECL void yasm_intnum_get_sized | ( | const yasm_intnum * | intn, |
unsigned char * | ptr, | ||
size_t | destsize, | ||
size_t | valsize, | ||
int | shift, | ||
int | bigendian, | ||
int | warn | ||
) |
Output yasm_intnum to buffer in little-endian or big-endian.
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. [0] should be the first byte output to the file.
intn | intnum |
ptr | pointer to storage for size bytes of output |
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) |
bigendian | endianness (nonzero=big, zero=little) |
warn | enables standard warnings (value doesn't fit into valsize bits): <0=signed warnings, >0=unsigned warnings, 0=no warn |
YASM_LIB_DECL char* yasm_intnum_get_str | ( | const yasm_intnum * | intn | ) |
Get an intnum as a signed decimal string.
The returned string will contain a leading '-' if the intnum is negative.
intn | intnum |
YASM_LIB_DECL unsigned long yasm_intnum_get_uint | ( | const yasm_intnum * | intn | ) |
Convert an intnum to an unsigned 32-bit value.
The value is in "standard" C format (eg, of unknown endian).
intn | intnum |
YASM_LIB_DECL int yasm_intnum_in_range | ( | const yasm_intnum * | intn, |
long | low, | ||
long | high | ||
) |
Check to see if intnum will fit into a particular numeric range.
intn | intnum |
low | low end of range (inclusive) |
high | high end of range (inclusive) |
YASM_LIB_DECL void yasm_intnum_initialize | ( | void | ) |
Initialize intnum internal data structures.
YASM_LIB_DECL int yasm_intnum_is_neg1 | ( | const yasm_intnum * | acc | ) |
Simple value check for -1.
acc | intnum |
YASM_LIB_DECL int yasm_intnum_is_pos1 | ( | const yasm_intnum * | acc | ) |
Simple value check for 1.
acc | intnum |
YASM_LIB_DECL int yasm_intnum_is_zero | ( | const yasm_intnum * | acc | ) |
Simple value check for 0.
acc | intnum |
YASM_LIB_DECL void yasm_intnum_print | ( | const yasm_intnum * | intn, |
FILE * | f | ||
) |
Print an intnum.
For debugging purposes.
f | file |
intn | intnum |
YASM_LIB_DECL void yasm_intnum_set | ( | yasm_intnum * | intn, |
const yasm_intnum * | val | ||
) |
Set an intnum to the value of another intnum.
intn | intnum |
val | intnum to get value from |
YASM_LIB_DECL void yasm_intnum_set_int | ( | yasm_intnum * | intn, |
long | val | ||
) |
Set an intnum to an signed integer.
intn | intnum |
val | integer value |
YASM_LIB_DECL void yasm_intnum_set_uint | ( | yasm_intnum * | intn, |
unsigned long | val | ||
) |
Set an intnum to an unsigned integer.
intn | intnum |
val | integer value |
YASM_LIB_DECL int yasm_intnum_sign | ( | const yasm_intnum * | acc | ) |
Simple sign check.
acc | intnum |
YASM_LIB_DECL unsigned long yasm_intnum_size_leb128 | ( | const yasm_intnum * | intn, |
int | sign | ||
) |
Calculate number of bytes LEB128-encoded form of yasm_intnum will take.
intn | intnum |
sign | signedness of LEB128 encoding (0=unsigned, 1=signed) |
YASM_LIB_DECL void yasm_intnum_zero | ( | yasm_intnum * | intn | ) |
Zero an intnum.
intn | intnum |
YASM_LIB_DECL unsigned long yasm_size_sleb128 | ( | long | v | ) |
Calculate number of bytes signed LEB128-encoded form of integer will take.
v | integer |
YASM_LIB_DECL unsigned long yasm_size_uleb128 | ( | unsigned long | v | ) |
Calculate number of bytes unsigned LEB128-encoded form of integer will take.
v | integer |