00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00033
00034
00035
00036 #ifndef _XED_STATE_H_
00037 # define _XED_STATE_H_
00038 #include "xed-types.h"
00039 #include "xed-portability.h"
00040 #include "xed-address-width-enum.h"
00041 #include "xed-machine-mode-enum.h"
00042
00043
00052 typedef struct XED_DLL_EXPORT xed_state_s {
00054 xed_machine_mode_enum_t mmode;
00056 xed_address_width_enum_t stack_addr_width;
00057 } xed_state_t;
00058
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 static XED_INLINE void xed_state_init(xed_state_t* p,
00074 xed_machine_mode_enum_t arg_mmode,
00075 xed_address_width_enum_t arg_ignored,
00076 xed_address_width_enum_t arg_stack_addr_width) {
00077 p->mmode=arg_mmode;
00078 p->stack_addr_width=arg_stack_addr_width;
00079 (void) arg_ignored;
00080 }
00081
00092 static XED_INLINE void xed_state_init2(xed_state_t* p,
00093 xed_machine_mode_enum_t arg_mmode,
00094 xed_address_width_enum_t arg_stack_addr_width) {
00095 p->mmode=arg_mmode;
00096 p->stack_addr_width=arg_stack_addr_width;
00097 }
00098
00101 static XED_INLINE void xed_state_zero(xed_state_t* p) {
00102 p->mmode= XED_MACHINE_MODE_INVALID;
00103 p->stack_addr_width=XED_ADDRESS_WIDTH_INVALID;
00104 }
00105
00107
00109
00110
00111
00112 static XED_INLINE xed_machine_mode_enum_t xed_state_get_machine_mode(const xed_state_t* p) {
00113 return p->mmode;
00114 }
00115
00116
00119 static XED_INLINE xed_bool_t xed_state_long64_mode(const xed_state_t* p) {
00120 return xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_64;
00121 }
00122
00124 static XED_INLINE xed_bool_t xed_state_real_mode(const xed_state_t* p) {
00125 return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_REAL_16);
00126 }
00127
00129 static XED_INLINE xed_bool_t xed_state_mode_width_16(const xed_state_t* p) {
00130 return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LEGACY_16) ||
00131 (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_COMPAT_16);
00132 }
00133
00135 static XED_INLINE xed_bool_t xed_state_mode_width_32(const xed_state_t* p) {
00136 return (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LEGACY_32) ||
00137 (xed_state_get_machine_mode(p) == XED_MACHINE_MODE_LONG_COMPAT_32);
00138 }
00139
00140
00143 static XED_INLINE void xed_state_set_machine_mode( xed_state_t* p,
00144 xed_machine_mode_enum_t arg_mode) {
00145 p->mmode = arg_mode;
00146 }
00148
00150
00151
00152
00153 static XED_INLINE void xed_state_set_address_width(xed_state_t* p,
00154 xed_address_width_enum_t arg_addr_width) {
00155 (void)p;
00156 (void)arg_addr_width;
00157 }
00158
00161 static XED_INLINE xed_address_width_enum_t xed_state_get_address_width(const xed_state_t* p) {
00162 switch(xed_state_get_machine_mode(p)) {
00163 case XED_MACHINE_MODE_LONG_64:
00164 return XED_ADDRESS_WIDTH_64b;
00165
00166 case XED_MACHINE_MODE_REAL_16:
00167
00168
00169
00170 return XED_ADDRESS_WIDTH_32b;
00171
00172 case XED_MACHINE_MODE_LEGACY_32:
00173 case XED_MACHINE_MODE_LONG_COMPAT_32:
00174 return XED_ADDRESS_WIDTH_32b;
00175 case XED_MACHINE_MODE_LEGACY_16:
00176 case XED_MACHINE_MODE_LONG_COMPAT_16:
00177 return XED_ADDRESS_WIDTH_16b;
00178 default:
00179 return XED_ADDRESS_WIDTH_INVALID;
00180 }
00181 }
00182
00184
00186
00187
00188
00189 static XED_INLINE void xed_state_set_stack_address_width(xed_state_t* p,
00190 xed_address_width_enum_t arg_addr_width) {
00191 p->stack_addr_width = arg_addr_width;
00192 }
00193
00194
00197 static XED_INLINE xed_address_width_enum_t xed_state_get_stack_address_width(const xed_state_t* p) {
00198 return p->stack_addr_width;
00199 }
00201
00203 XED_DLL_EXPORT int xed_state_print(const xed_state_t* p, char* buf, int buflen);
00204
00205 #endif
00206
00208
00209
00210