Intel® X86 Encoder Decoder
xed-immdis.h File Reference
#include "xed-types.h"
#include "xed-common-defs.h"
#include "xed-util.h"

Data Structures

struct  xed_immdis_s
 Stores immediates and displacements for the encoder & decoder. More...
 
union  xed_immdis_values_t
 

Macros

#define XED_MAX_IMMDIS_BYTES   8
 

Typedefs

typedef struct xed_immdis_s xed_immdis_t
 Stores immediates and displacements for the encoder & decoder. More...
 

Functions

XED_DLL_EXPORT void xed_immdis_init (xed_immdis_t *p, xed_uint_t max_bytes)
 
Sizes and lengths
XED_DLL_EXPORT unsigned int xed_immdis_get_bytes (const xed_immdis_t *p)
 return the number of bytes added More...
 
Accessors for the value of the immediate or displacement
XED_DLL_EXPORT xed_uint8_t xed_immdis_get_byte (const xed_immdis_t *p, unsigned int i)
 Access the i'th byte of the immediate. More...
 
XED_DLL_EXPORT xed_int64_t xed_immdis_get_signed64 (const xed_immdis_t *p)
 
XED_DLL_EXPORT xed_uint64_t xed_immdis_get_unsigned64 (const xed_immdis_t *p)
 
XED_DLL_EXPORT xed_bool_t xed_immdis_is_one (const xed_immdis_t *p)
 
XED_DLL_EXPORT xed_bool_t xed_immdis_is_zero (const xed_immdis_t *p)
 
Presence / absence of an immediate or displacement
XED_DLL_EXPORT xed_bool_t xed_immdis_is_present (const xed_immdis_t *p)
 True if the object has had a value or individual bytes added to it. More...
 
XED_DLL_EXPORT void xed_immdis_set_present (xed_immdis_t *p)
 
Initialization and setup
XED_DLL_EXPORT unsigned int xed_immdis_get_max_length (const xed_immdis_t *p)
 
XED_DLL_EXPORT void xed_immdis_set_max_len (xed_immdis_t *p, unsigned int mx)
 
XED_DLL_EXPORT void xed_immdis_zero (xed_immdis_t *p)
 
Signed vs Unsigned
XED_DLL_EXPORT xed_bool_t xed_immdis_is_signed (const xed_immdis_t *p)
 Return true if signed. More...
 
XED_DLL_EXPORT xed_bool_t xed_immdis_is_unsigned (const xed_immdis_t *p)
 Return true if signed. More...
 
XED_DLL_EXPORT void xed_immdis_set_signed (xed_immdis_t *p)
 Set the immediate to be signed; For decoder use only. More...
 
XED_DLL_EXPORT void xed_immdis_set_unsigned (xed_immdis_t *p)
 Set the immediate to be unsigned; For decoder use only. More...
 
Adding / setting values
XED_DLL_EXPORT void xed_immdis_add16 (xed_immdis_t *p, xed_int16_t d)
 add a 16 bit value to the byte array More...
 
XED_DLL_EXPORT void xed_immdis_add32 (xed_immdis_t *p, xed_int32_t d)
 add a 32 bit value to the byte array More...
 
XED_DLL_EXPORT void xed_immdis_add64 (xed_immdis_t *p, xed_int64_t d)
 add a 64 bit value to the byte array. More...
 
XED_DLL_EXPORT void xed_immdis_add8 (xed_immdis_t *p, xed_int8_t d)
 add an 8 bit value to the byte array More...
 
XED_DLL_EXPORT void xed_immdis_add_byte (xed_immdis_t *p, xed_uint8_t b)
 
XED_DLL_EXPORT void xed_immdis_add_byte_array (xed_immdis_t *p, int nb, xed_uint8_t *ba)
 
XED_DLL_EXPORT void xed_immdis_add_shortest_width_signed (xed_immdis_t *p, xed_int64_t x, xed_uint8_t legal_widths)
 Add 1, 2, 4 or 8 bytes depending on the value x and the mask of legal_widths. More...
 
XED_DLL_EXPORT void xed_immdis_add_shortest_width_unsigned (xed_immdis_t *p, xed_uint64_t x, xed_uint8_t legal_widths)
 See add_shortest_width_signed() More...
 
printing / debugging
XED_DLL_EXPORT int xed_immdis_print (const xed_immdis_t *p, char *buf, int buflen)
 just print the raw bytes in hex with a leading 0x More...
 
XED_DLL_EXPORT int xed_immdis_print_signed_or_unsigned (const xed_immdis_t *p, char *buf, int buflen)
 Print the value as a signed or unsigned number depending on the value of the immediate_is_unsigned variable. More...
 
XED_DLL_EXPORT int xed_immdis_print_value_signed (const xed_immdis_t *p, char *buf, int buflen)
 print the signed value, appropriate width, with a leading 0x More...
 
XED_DLL_EXPORT int xed_immdis_print_value_unsigned (const xed_immdis_t *p, char *buf, int buflen)
 print the unsigned value, appropriate width, with a leading 0x More...
 

Macro Definition Documentation

◆ XED_MAX_IMMDIS_BYTES

#define XED_MAX_IMMDIS_BYTES   8

Typedef Documentation

◆ xed_immdis_t

typedef struct xed_immdis_s xed_immdis_t

Stores immediates and displacements for the encoder & decoder.

Function Documentation

◆ xed_immdis_add16()

XED_DLL_EXPORT void xed_immdis_add16 ( xed_immdis_t p,
xed_int16_t  d 
)

add a 16 bit value to the byte array

◆ xed_immdis_add32()

XED_DLL_EXPORT void xed_immdis_add32 ( xed_immdis_t p,
xed_int32_t  d 
)

add a 32 bit value to the byte array

◆ xed_immdis_add64()

XED_DLL_EXPORT void xed_immdis_add64 ( xed_immdis_t p,
xed_int64_t  d 
)

add a 64 bit value to the byte array.

◆ xed_immdis_add8()

XED_DLL_EXPORT void xed_immdis_add8 ( xed_immdis_t p,
xed_int8_t  d 
)

add an 8 bit value to the byte array

◆ xed_immdis_add_byte()

XED_DLL_EXPORT void xed_immdis_add_byte ( xed_immdis_t p,
xed_uint8_t  b 
)

◆ xed_immdis_add_byte_array()

XED_DLL_EXPORT void xed_immdis_add_byte_array ( xed_immdis_t p,
int  nb,
xed_uint8_t *  ba 
)

◆ xed_immdis_add_shortest_width_signed()

XED_DLL_EXPORT void xed_immdis_add_shortest_width_signed ( xed_immdis_t p,
xed_int64_t  x,
xed_uint8_t  legal_widths 
)

Add 1, 2, 4 or 8 bytes depending on the value x and the mask of legal_widths.

The default value of legal_widths = 0x5 only stops adding bytes only on 1 or 4 byte quantities - depending on which bytes of x are zero – as is used for most memory addressing. You can set legal_widths to 0x7 for branches (1, 2 or 4 byte branch displacements). Or if you have an 8B displacement, you can set legal_widths to 0x8. NOTE: add_shortest_width will add up to XED_MAX_IMMDIS_BYTES if the x value requires it. NOTE: 16b memory addressing can have 16b immediates.

◆ xed_immdis_add_shortest_width_unsigned()

XED_DLL_EXPORT void xed_immdis_add_shortest_width_unsigned ( xed_immdis_t p,
xed_uint64_t  x,
xed_uint8_t  legal_widths 
)

See add_shortest_width_signed()

◆ xed_immdis_get_byte()

XED_DLL_EXPORT xed_uint8_t xed_immdis_get_byte ( const xed_immdis_t p,
unsigned int  i 
)

Access the i'th byte of the immediate.

◆ xed_immdis_get_bytes()

XED_DLL_EXPORT unsigned int xed_immdis_get_bytes ( const xed_immdis_t p)

return the number of bytes added

◆ xed_immdis_get_max_length()

XED_DLL_EXPORT unsigned int xed_immdis_get_max_length ( const xed_immdis_t p)

◆ xed_immdis_get_signed64()

XED_DLL_EXPORT xed_int64_t xed_immdis_get_signed64 ( const xed_immdis_t p)

◆ xed_immdis_get_unsigned64()

XED_DLL_EXPORT xed_uint64_t xed_immdis_get_unsigned64 ( const xed_immdis_t p)

◆ xed_immdis_init()

XED_DLL_EXPORT void xed_immdis_init ( xed_immdis_t p,
xed_uint_t  max_bytes 
)

◆ xed_immdis_is_one()

XED_DLL_EXPORT xed_bool_t xed_immdis_is_one ( const xed_immdis_t p)

◆ xed_immdis_is_present()

XED_DLL_EXPORT xed_bool_t xed_immdis_is_present ( const xed_immdis_t p)

True if the object has had a value or individual bytes added to it.

◆ xed_immdis_is_signed()

XED_DLL_EXPORT xed_bool_t xed_immdis_is_signed ( const xed_immdis_t p)

Return true if signed.

◆ xed_immdis_is_unsigned()

XED_DLL_EXPORT xed_bool_t xed_immdis_is_unsigned ( const xed_immdis_t p)

Return true if signed.

◆ xed_immdis_is_zero()

XED_DLL_EXPORT xed_bool_t xed_immdis_is_zero ( const xed_immdis_t p)

◆ xed_immdis_print()

XED_DLL_EXPORT int xed_immdis_print ( const xed_immdis_t p,
char *  buf,
int  buflen 
)

just print the raw bytes in hex with a leading 0x

◆ xed_immdis_print_signed_or_unsigned()

XED_DLL_EXPORT int xed_immdis_print_signed_or_unsigned ( const xed_immdis_t p,
char *  buf,
int  buflen 
)

Print the value as a signed or unsigned number depending on the value of the immediate_is_unsigned variable.

◆ xed_immdis_print_value_signed()

XED_DLL_EXPORT int xed_immdis_print_value_signed ( const xed_immdis_t p,
char *  buf,
int  buflen 
)

print the signed value, appropriate width, with a leading 0x

◆ xed_immdis_print_value_unsigned()

XED_DLL_EXPORT int xed_immdis_print_value_unsigned ( const xed_immdis_t p,
char *  buf,
int  buflen 
)

print the unsigned value, appropriate width, with a leading 0x

◆ xed_immdis_set_max_len()

XED_DLL_EXPORT void xed_immdis_set_max_len ( xed_immdis_t p,
unsigned int  mx 
)

◆ xed_immdis_set_present()

XED_DLL_EXPORT void xed_immdis_set_present ( xed_immdis_t p)

◆ xed_immdis_set_signed()

XED_DLL_EXPORT void xed_immdis_set_signed ( xed_immdis_t p)

Set the immediate to be signed; For decoder use only.

◆ xed_immdis_set_unsigned()

XED_DLL_EXPORT void xed_immdis_set_unsigned ( xed_immdis_t p)

Set the immediate to be unsigned; For decoder use only.

◆ xed_immdis_zero()

XED_DLL_EXPORT void xed_immdis_zero ( xed_immdis_t p)