- Main Page
- Modules
- Data Structures
- Files

- Search for |

- File List
- Globals

# xed-immdis.h File Reference

`#include "xed-types.h"`
`#include "xed-common-defs.h"`
`#include "xed-util.h"`

Go to the source code of this file.

## Data Structures

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

## printing / debugging

int | xed_immdis__print_ptr (const xed_immdis_t *p, char *buf, int buflen)
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_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_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_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

## 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
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_DLL_EXPORT void | xed_immdis_add64 (xed_immdis_t *p, xed_int64_t d)
| add a 64 bit value to the byte array.
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_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.
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().

## 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.
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)

## Sizes and lengths

XED_DLL_EXPORT unsigned int | xed_immdis_get_bytes (const xed_immdis_t *p)
| return the number of bytes added

## 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)

## 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.
XED_DLL_EXPORT void | xed_immdis_set_present (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.
XED_DLL_EXPORT xed_bool_t | xed_immdis_is_unsigned (const xed_immdis_t *p)
| Return true if signed.
XED_DLL_EXPORT void | xed_immdis_set_signed (xed_immdis_t *p)
| Set the immediate to be signed; For decoder use only.
XED_DLL_EXPORT void | xed_immdis_set_unsigned (xed_immdis_t *p)
| Set the immediate to be unsigned; For decoder use only.

## Defines

#define | XED_MAX_IMMDIS_BYTES 8

## Typedefs

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

## Functions

XED_DLL_EXPORT void | xed_immdis__check (xed_immdis_t *q, int p)
XED_DLL_EXPORT void | xed_immdis_init (xed_immdis_t *p, int max_bytes)

## Detailed Description

Definition in file xed-immdis.h.

## Define Documentation

#define XED_MAX_IMMDIS_BYTES 8

| Definition at line 59 of file xed-immdis.h.

## Typedef Documentation

typedef struct xed_immdis_s xed_immdis_t

| Stores immediates and displacements for the encoder & decoder.

## Function Documentation

XED_DLL_EXPORT void xed_immdis__check | ( | xed_immdis_t * | q,
|  | int | p
| ) |

int xed_immdis__print_ptr | ( | const xed_immdis_t * | p,
|  | char * | buf,
|  | int | buflen
| ) |

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_DLL_EXPORT void xed_immdis_add32 | ( | xed_immdis_t * | p,
|  | xed_int32_t | d
| ) |

| add a 32 bit value to the byte array

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_DLL_EXPORT void xed_immdis_add8 | ( | xed_immdis_t * | p,
|  | xed_int8_t | d
| ) |

| add an 8 bit value to the byte array

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. 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_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_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_DLL_EXPORT unsigned int xed_immdis_get_bytes | ( | const xed_immdis_t * | p | ) |

| return the number of bytes added

XED_DLL_EXPORT unsigned int xed_immdis_get_max_length | ( | const xed_immdis_t * | p | ) |

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 void xed_immdis_init | ( | xed_immdis_t * | p,
|  | int | max_bytes
| ) |

XED_DLL_EXPORT xed_bool_t xed_immdis_is_one | ( | const xed_immdis_t * | p | ) |

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_DLL_EXPORT xed_bool_t xed_immdis_is_signed | ( | const xed_immdis_t * | p | ) |

| Return true if signed.

XED_DLL_EXPORT xed_bool_t xed_immdis_is_unsigned | ( | const xed_immdis_t * | p | ) |

| Return true if signed.

XED_DLL_EXPORT xed_bool_t xed_immdis_is_zero | ( | const xed_immdis_t * | p | ) |

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_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_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_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_DLL_EXPORT void xed_immdis_set_max_len | ( | xed_immdis_t * | p,
|  | unsigned int | mx
| ) |

XED_DLL_EXPORT void xed_immdis_set_present | ( | xed_immdis_t * | p | ) |

XED_DLL_EXPORT void xed_immdis_set_signed | ( | xed_immdis_t * | p | ) |

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

XED_DLL_EXPORT void xed_immdis_set_unsigned | ( | xed_immdis_t * | p | ) |

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

XED_DLL_EXPORT void xed_immdis_zero | ( | xed_immdis_t * | p | ) |