Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

x86asm Class Reference

#include <x86asm.h>

Inheritance diagram for x86asm:

Assembler Object List of all members.

Public Member Functions

 x86asm (int opsize, int addrsize)
virtual ~x86asm ()
virtual asm_insnalloc_insn ()
virtual asm_codeencode (asm_insn *asm_insn, int options, CPU_ADDR cur_address)
virtual char * get_name ()
virtual int translate_str (asm_insn *asm_insn, const char *s)

Public Attributes

int opsize
int addrsize

Protected Member Functions

void delete_nonsense ()
int delete_nonsense_insn (asm_code *c)
void emitdisp (dword disp, int size)
void emitfarptr (dword s, dword o, bool big)
void emitimm (dword imm, int size)
void emitmodrm (int modrm)
void emitmodrm_mod (int mod)
void emitmodrm_reg (int reg)
void emitmodrm_rm (int rm)
void emitsib_base (int base)
void emitsib_index (int index)
void emitsib_scale (int scale)
int encode_insn (x86asm_insn *insn, x86opc_insn *opcode, int opcodeb, int additional_opcode, int prefix, int eopsize, int eaddrsize)
int encode_modrm (x86_insn_op *op, char size, int allow_reg, int allow_mem, int eopsize, int eaddrsize)
int encode_modrm_v (x86addrcoding(*modrmc)[3][8], x86_insn_op *op, int mindispsize, int *mod, int *rm, int *dispsize)
int encode_op (x86_insn_op *op, x86opc_insn_op *xop, int *esize, int eopsize, int eaddrsize)
int encode_sib_v (x86_insn_op *op, int mindispsize, int *ss, int *index, int *base, int *mod, int *dispsize, int *disp)
int esizeaddr (char c, int size)
int esizeop (char c, int size)
int fetch_number (char **s, dword *value)
char flsz2hsz (int size)
char * immlsz2hsz (int size, int opsize)
char * lsz2hsz (int size, int opsize)
int match_allops (x86asm_insn *insn, x86opc_insn *xinsn, int opsize, int addrsize)
void match_fopcodes (x86asm_insn *insn)
void match_opcode (x86opc_insn *opcode, x86asm_insn *insn, int prefix, byte opcodebyte, int additional_opcode)
int match_opcode_name (char *input_name, char *opcodelist_name)
int match_opcode_final (x86opc_insn *opcode, x86asm_insn *insn, int prefix, byte opcodebyte, int additional_opcode, int opsize, int addrsize)
void match_opcodes (x86opc_insn *opcodes, x86asm_insn *insn, int prefix)
int match_size (x86_insn_op *op, x86opc_insn_op *xop, int opsize)
int match_type (x86_insn_op *op, x86opc_insn_op *xop, int addrsize)
int opfarptr (x86_insn_op *op, char *xop)
int opimm (x86_insn_op *op, char *xop)
int opplugimm (x86_insn_op *op, char *xop)
int opmem (x86asm_insn *asm_insn, x86_insn_op *op, char *xop)
int opreg (x86_insn_op *op, char *xop)
int opseg (x86_insn_op *op, char *xop)
int opspecialregs (x86_insn_op *op, char *xop)
int simmsize (dword imm, int immsize)
void splitstr (const char *s, char *name, char *op[3])

Protected Attributes

int esizes [3]
int modrmv
int sibv
int disp
int dispsize
int imm
int imm2
int immsize
int address
bool ambiguous
bool namefound
bool addrsize_depend

Constructor & Destructor Documentation

x86asm::x86asm int  opsize,
int  addrsize
 

Definition at line 192 of file x86asm.cc.

References addrsize, false, and opsize.

x86asm::~x86asm  )  [virtual]
 

Definition at line 199 of file x86asm.cc.


Member Function Documentation

asm_insn * x86asm::alloc_insn  )  [virtual]
 

Reimplemented from Assembler.

Definition at line 203 of file x86asm.cc.

References asm_insn, and malloc().

void x86asm::delete_nonsense  )  [protected]
 

Definition at line 208 of file x86asm.cc.

References delete_nonsense_insn(), and asm_code::next.

Referenced by encode().

int x86asm::delete_nonsense_insn asm_code c  )  [protected]
 

Definition at line 218 of file x86asm.cc.

References byte, asm_code::context, asm_code::data, Assembler::deletecode(), asm_code::next, asm_code::size, and size.

Referenced by delete_nonsense().

void x86asm::emitdisp dword  disp,
int  size
[protected]
 

Definition at line 247 of file x86asm.cc.

References disp, dispsize, and size.

Referenced by encode_modrm(), and encode_op().

void x86asm::emitfarptr dword  s,
dword  o,
bool  big
[protected]
 

Definition at line 259 of file x86asm.cc.

References imm, imm2, and immsize.

Referenced by encode_op().

void x86asm::emitimm dword  imm,
int  size
[protected]
 

Definition at line 253 of file x86asm.cc.

References imm, immsize, and size.

Referenced by encode_op().

void x86asm::emitmodrm int  modrm  )  [protected]
 

Definition at line 271 of file x86asm.cc.

References modrmv.

Referenced by encode_insn().

void x86asm::emitmodrm_mod int  mod  )  [protected]
 

Definition at line 277 of file x86asm.cc.

References modrmv.

Referenced by encode_modrm().

void x86asm::emitmodrm_reg int  reg  )  [protected]
 

Definition at line 283 of file x86asm.cc.

References modrmv.

Referenced by encode_insn(), and encode_op().

void x86asm::emitmodrm_rm int  rm  )  [protected]
 

Definition at line 289 of file x86asm.cc.

References modrmv.

Referenced by encode_modrm(), and encode_op().

void x86asm::emitsib_base int  base  )  [protected]
 

Definition at line 295 of file x86asm.cc.

References sibv.

Referenced by encode_modrm().

void x86asm::emitsib_index int  index  )  [protected]
 

Definition at line 301 of file x86asm.cc.

References sibv.

Referenced by encode_modrm().

void x86asm::emitsib_scale int  scale  )  [protected]
 

Definition at line 307 of file x86asm.cc.

References sibv.

Referenced by encode_modrm().

asm_code * x86asm::encode asm_insn asm_insn,
int  options,
CPU_ADDR  cur_address
[virtual]
 

Reimplemented from Assembler.

Definition at line 313 of file x86asm.cc.

References CPU_ADDR::addr32, address, addrsize_depend, ambiguous, asm_insn, delete_nonsense(), Assembler::encode(), esizes, Assembler::free_asm_codes(), match_fopcodes(), match_opcodes(), x86asm_insn::name, namefound, Assembler::newcode(), x86asm_insn::op, options, Assembler::set_error_msg(), x86_insn_op::type, x86_insns, x86_insns_ext, X86_OPTYPE_MEM, X86ASM_ERRMSG_INVALID_OPERANDS, X86ASM_ERRMSG_UNKNOWN_COMMAND, X86ASM_PREFIX_0F, and X86ASM_PREFIX_NO.

int x86asm::encode_insn x86asm_insn insn,
x86opc_insn opcode,
int  opcodeb,
int  additional_opcode,
int  prefix,
int  eopsize,
int  eaddrsize
[protected]
 

Definition at line 350 of file x86asm.cc.

References addrsize, Assembler::clearcode(), asm_code::context, disp, dispsize, Assembler::emitbyte(), Assembler::emitdword(), emitmodrm(), emitmodrm_reg(), Assembler::emitword(), encode_op(), esizes, imm, imm2, immsize, x86asm_insn::lockprefix, modrmv, x86asm_insn::op, x86opc_insn::op, opsize, x86asm_insn::repprefix, x86asm_insn::segprefix, sibv, x86opc_insn_op::size, SIZE_C, SIZE_P, SIZE_V, X86_PREFIX_CS, X86_PREFIX_DS, X86_PREFIX_ES, X86_PREFIX_FS, X86_PREFIX_GS, X86_PREFIX_LOCK, X86_PREFIX_REPNZ, X86_PREFIX_REPZ, X86_PREFIX_SS, X86ASM_PREFIX_0F, X86ASM_PREFIX_0F0F, X86ASM_PREFIX_D8, X86ASM_PREFIX_D9, X86ASM_PREFIX_DA, X86ASM_PREFIX_DB, X86ASM_PREFIX_DC, X86ASM_PREFIX_DD, X86ASM_PREFIX_DE, X86ASM_PREFIX_DF, and X86ASM_PREFIX_NO.

Referenced by match_fopcodes(), and match_opcode_final().

int x86asm::encode_modrm x86_insn_op op,
char  size,
int  allow_reg,
int  allow_mem,
int  eopsize,
int  eaddrsize
[protected]
 

Definition at line 452 of file x86asm.cc.

References addrsize, disp, dispsize, emitdisp(), emitmodrm_mod(), emitmodrm_rm(), emitsib_base(), emitsib_index(), emitsib_scale(), encode_modrm_v(), encode_sib_v(), x86_insn_op::mem, modrm16, modrm32, x86_insn_op::reg, simmsize(), x86_insn_op::type, X86_ADDRSIZE16, X86_ADDRSIZEUNKNOWN, X86_OPTYPE_MEM, and X86_OPTYPE_REG.

Referenced by encode_op().

int x86asm::encode_modrm_v x86addrcoding modrmc[3][8],
x86_insn_op op,
int  mindispsize,
int *  mod,
int *  rm,
int *  dispsize
[protected]
 

Definition at line 499 of file x86asm.cc.

References x86addrcoding::dispsize, x86_insn_op::mem, x86addrcoding::reg1, and x86addrcoding::reg2.

Referenced by encode_modrm().

int x86asm::encode_op x86_insn_op op,
x86opc_insn_op xop,
int *  esize,
int  eopsize,
int  eaddrsize
[protected]
 

Definition at line 522 of file x86asm.cc.

References address, x86_insn_op::crx, x86_insn_op::drx, emitdisp(), emitfarptr(), emitimm(), emitmodrm_reg(), emitmodrm_rm(), encode_modrm(), esizeop(), x86opc_insn_op::extendedsize, x86_insn_op::farptr, x86_insn_op::imm, x86_insn_op::mem, x86_insn_op::reg, x86_insn_op::seg, asm_code::size, x86opc_insn_op::size, size, x86_insn_op::size, x86_insn_op::stx, x86_insn_op::trx, x86_insn_op::type, x86opc_insn_op::type, TYPE_0, TYPE_A, TYPE_C, TYPE_D, TYPE_E, TYPE_F, TYPE_Fx, TYPE_G, TYPE_I, TYPE_Is, TYPE_Ix, TYPE_J, TYPE_M, TYPE_O, TYPE_P, TYPE_Q, TYPE_R, TYPE_Rx, TYPE_S, TYPE_Sx, TYPE_T, X86_ADDRSIZE16, X86_ADDRSIZE32, X86_OPTYPE_FARPTR, and X86_REG_NO.

Referenced by encode_insn().

int x86asm::encode_sib_v x86_insn_op op,
int  mindispsize,
int *  ss,
int *  index,
int *  base,
int *  mod,
int *  dispsize,
int *  disp
[protected]
 

Definition at line 639 of file x86asm.cc.

References dispsize, x86_insn_op::mem, X86_REG_BP, X86_REG_NO, and X86_REG_SP.

Referenced by encode_modrm().

int x86asm::esizeaddr char  c,
int  size
[protected]
 

Definition at line 719 of file x86asm.cc.

References size, SIZE_A, SIZE_B, SIZE_C, SIZE_D, SIZE_P, SIZE_Q, SIZE_V, SIZE_W, and X86_ADDRSIZE16.

int x86asm::esizeop char  c,
int  size
[protected]
 

Definition at line 742 of file x86asm.cc.

References size, SIZE_B, SIZE_C, SIZE_D, SIZE_L, SIZE_P, SIZE_Q, SIZE_S, SIZE_T, SIZE_V, SIZE_W, and X86_OPSIZE16.

Referenced by encode_op(), and match_size().

int x86asm::fetch_number char **  s,
dword *  value
[protected]
 

Definition at line 769 of file x86asm.cc.

References dword, and value.

Referenced by opfarptr(), opimm(), and opmem().

char x86asm::flsz2hsz int  size  )  [protected]
 

Definition at line 789 of file x86asm.cc.

References size, SIZE_L, SIZE_S, and SIZE_T.

Referenced by match_size().

char * x86asm::get_name  )  [virtual]
 

Reimplemented from Assembler.

Definition at line 802 of file x86asm.cc.

char * x86asm::immlsz2hsz int  size,
int  opsize
[protected]
 

Definition at line 807 of file x86asm.cc.

References immhsz16_16, immhsz16_32, immhsz32_16, immhsz32_32, immhsz8_16, immhsz8_32, size, and X86_OPSIZE16.

Referenced by match_size().

char * x86asm::lsz2hsz int  size,
int  opsize
[protected]
 

Definition at line 831 of file x86asm.cc.

References hsz16_16, hsz16_32, hsz32_16, hsz32_32, hsz48_16, hsz48_32, hsz64_16, hsz64_32, hsz8_16, hsz8_32, size, and X86_OPSIZE16.

Referenced by match_size().

int x86asm::match_allops x86asm_insn insn,
x86opc_insn xinsn,
int  opsize,
int  addrsize
[protected]
 

Definition at line 916 of file x86asm.cc.

References match_size(), match_type(), x86opc_insn::op, and x86asm_insn::op.

Referenced by match_fopcodes(), and match_opcode_final().

void x86asm::match_fopcodes x86asm_insn insn  )  [protected]
 

Definition at line 994 of file x86asm.cc.

References addrsize, encode_insn(), x86opc_finsn::group, x86opc_finsn::insn, match_allops(), match_opcode_name(), MATCHOPNAME_NOMATCH, x86opc_insn::name, x86asm_insn::name, namefound, Assembler::newcode(), opsize, Assembler::pushcode(), X86_ADDRSIZE16, X86_ADDRSIZE32, x86_float_group_insns, x86_modfloat_group_insns, and X86ASM_PREFIX_D8.

Referenced by encode().

void x86asm::match_opcode x86opc_insn opcode,
x86asm_insn insn,
int  prefix,
byte  opcodebyte,
int  additional_opcode
[protected]
 

Definition at line 949 of file x86asm.cc.

References addrsize, addrsize_depend, ADDRSIZE_INV, match_opcode_final(), match_opcode_name(), MATCHOPNAME_MATCH_IF_OPSIZE16, MATCHOPNAME_MATCH_IF_OPSIZE32, MATCHOPNAME_NOMATCH, x86opc_insn::name, x86asm_insn::name, namefound, opsize, OPSIZE_INV, X86_OPSIZE16, and X86_OPSIZE32.

Referenced by match_opcodes().

int x86asm::match_opcode_final x86opc_insn opcode,
x86asm_insn insn,
int  prefix,
byte  opcodebyte,
int  additional_opcode,
int  opsize,
int  addrsize
[protected]
 

Definition at line 965 of file x86asm.cc.

References encode_insn(), match_allops(), Assembler::newcode(), and Assembler::pushcode().

Referenced by match_opcode().

int x86asm::match_opcode_name char *  input_name,
char *  opcodelist_name
[protected]
 

Definition at line 930 of file x86asm.cc.

References MATCHOPNAME_MATCH, MATCHOPNAME_MATCH_IF_OPSIZE16, MATCHOPNAME_MATCH_IF_OPSIZE32, and MATCHOPNAME_NOMATCH.

Referenced by match_fopcodes(), and match_opcode().

void x86asm::match_opcodes x86opc_insn opcodes,
x86asm_insn insn,
int  prefix
[protected]
 

Definition at line 978 of file x86asm.cc.

References x86opc_insn_op_special::data, match_opcode(), x86opc_insn::name, x86opc_insn::op, SPECIAL_TYPE_GROUP, x86opc_insn_op_special::type, and x86_group_insns.

Referenced by encode().

int x86asm::match_size x86_insn_op op,
x86opc_insn_op xop,
int  opsize
[protected]
 

Definition at line 887 of file x86asm.cc.

References address, esizeop(), x86opc_insn_op::extendedsize, flsz2hsz(), x86_insn_op::imm, immlsz2hsz(), lsz2hsz(), x86_insn_op::mem, NULL, simmsize(), asm_code::size, size, x86opc_insn_op::size, x86_insn_op::size, x86opc_insn_op::type, x86_insn_op::type, TYPE_0, TYPE_Is, TYPE_J, X86_OPTYPE_EMPTY, X86_OPTYPE_IMM, X86_OPTYPE_MEM, and X86_OPTYPE_STX.

Referenced by match_allops().

int x86asm::match_type x86_insn_op op,
x86opc_insn_op xop,
int  addrsize
[protected]
 

Definition at line 863 of file x86asm.cc.

References x86opc_insn_op::extra, x86_insn_op::imm, lop2hop, x86_insn_op::mem, x86_insn_op::reg, x86_insn_op::seg, x86_insn_op::stx, x86opc_insn_op::type, x86_insn_op::type, TYPE_0, TYPE_Fx, TYPE_Ix, TYPE_Rx, TYPE_Sx, X86_ADDRSIZEUNKNOWN, X86_OPTYPE_EMPTY, and X86_OPTYPE_MEM.

Referenced by match_allops().

int x86asm::opfarptr x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1083 of file x86asm.cc.

References dword, x86_insn_op::farptr, fetch_number(), x86_insn_op::size, x86_insn_op::type, and X86_OPTYPE_FARPTR.

Referenced by translate_str().

int x86asm::opimm x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1099 of file x86asm.cc.

References dword, fetch_number(), x86_insn_op::imm, x86_insn_op::size, x86_insn_op::type, and X86_OPTYPE_IMM.

Referenced by translate_str().

int x86asm::opmem x86asm_insn asm_insn,
x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1123 of file x86asm.cc.

References addrsize, asm_insn, buf, disp, dword, fetch_number(), Assembler::imm_eval_proc, x86_insn_op::mem, opsize, x86_insn_op::size, x86_insn_op::type, X86_ADDRSIZE16, X86_ADDRSIZE32, X86_ADDRSIZEUNKNOWN, X86_OPTYPE_MEM, X86_PREFIX_CS, X86_PREFIX_DS, X86_PREFIX_ES, X86_PREFIX_FS, X86_PREFIX_GS, X86_PREFIX_SS, X86_REG_NO, x86_regs, and x86_segs.

Referenced by translate_str().

int x86asm::opplugimm x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1110 of file x86asm.cc.

References dword, x86_insn_op::imm, Assembler::imm_eval_proc, x86_insn_op::size, x86_insn_op::type, and X86_OPTYPE_IMM.

Referenced by translate_str().

int x86asm::opreg x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1055 of file x86asm.cc.

References x86_insn_op::reg, reg2size, x86_insn_op::size, x86_insn_op::type, X86_OPTYPE_REG, and x86_regs.

Referenced by translate_str().

int x86asm::opseg x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1070 of file x86asm.cc.

References x86_insn_op::seg, x86_insn_op::size, x86_insn_op::type, X86_OPTYPE_SEG, and x86_segs.

Referenced by translate_str().

int x86asm::opspecialregs x86_insn_op op,
char *  xop
[protected]
 

Definition at line 1305 of file x86asm.cc.

References x86_insn_op::crx, x86_insn_op::drx, x86_insn_op::size, x86_insn_op::stx, x86_insn_op::trx, x86_insn_op::type, X86_OPTYPE_CRX, X86_OPTYPE_DRX, X86_OPTYPE_STX, and X86_OPTYPE_TRX.

Referenced by translate_str().

int x86asm::simmsize dword  imm,
int  immsize
[protected]
 

Definition at line 1395 of file x86asm.cc.

References sint16, sint32, and sint8.

Referenced by encode_modrm(), and match_size().

void x86asm::splitstr const char *  s,
char *  name,
char *  op[3]
[protected]
 

Definition at line 1417 of file x86asm.cc.

References isnotwhitespace(), and iswhitespace().

Referenced by translate_str().

int x86asm::translate_str asm_insn asm_insn,
const char *  s
[virtual]
 

Reimplemented from Assembler.

Definition at line 1345 of file x86asm.cc.

References asm_insn, isnotwhitespace(), iswhitespace(), x86asm_insn::lockprefix, x86asm_insn::n, x86asm_insn::name, x86asm_insn::op, opfarptr(), opimm(), opmem(), opplugimm(), opreg(), opseg(), opspecialregs(), x86asm_insn::repprefix, x86asm_insn::segprefix, Assembler::set_error_msg(), splitstr(), x86_insn_op::type, X86_OPTYPE_EMPTY, X86_PREFIX_LOCK, X86_PREFIX_NO, X86_PREFIX_REPNZ, X86_PREFIX_REPZ, and X86ASM_ERRMSG_UNKNOWN_SYMBOL.


Member Data Documentation

int x86asm::address [protected]
 

Definition at line 63 of file x86asm.h.

Referenced by encode(), encode_op(), and match_size().

int x86asm::addrsize
 

Definition at line 52 of file x86asm.h.

Referenced by encode_insn(), encode_modrm(), match_fopcodes(), match_opcode(), opmem(), and x86asm().

bool x86asm::addrsize_depend [protected]
 

Definition at line 66 of file x86asm.h.

Referenced by encode(), and match_opcode().

bool x86asm::ambiguous [protected]
 

Definition at line 64 of file x86asm.h.

Referenced by encode().

int x86asm::disp [protected]
 

Definition at line 58 of file x86asm.h.

Referenced by emitdisp(), encode_insn(), encode_modrm(), and opmem().

int x86asm::dispsize [protected]
 

Definition at line 59 of file x86asm.h.

Referenced by emitdisp(), encode_insn(), encode_modrm(), and encode_sib_v().

int x86asm::esizes[3] [protected]
 

Definition at line 54 of file x86asm.h.

Referenced by encode(), and encode_insn().

int x86asm::imm [protected]
 

Definition at line 60 of file x86asm.h.

Referenced by emitfarptr(), emitimm(), and encode_insn().

int x86asm::imm2 [protected]
 

Definition at line 61 of file x86asm.h.

Referenced by emitfarptr(), and encode_insn().

int x86asm::immsize [protected]
 

Definition at line 62 of file x86asm.h.

Referenced by emitfarptr(), emitimm(), and encode_insn().

int x86asm::modrmv [protected]
 

Definition at line 56 of file x86asm.h.

Referenced by emitmodrm(), emitmodrm_mod(), emitmodrm_reg(), emitmodrm_rm(), and encode_insn().

bool x86asm::namefound [protected]
 

Definition at line 65 of file x86asm.h.

Referenced by encode(), match_fopcodes(), and match_opcode().

int x86asm::opsize
 

Definition at line 51 of file x86asm.h.

Referenced by encode_insn(), match_fopcodes(), match_opcode(), opmem(), and x86asm().

int x86asm::sibv [protected]
 

Definition at line 57 of file x86asm.h.

Referenced by emitsib_base(), emitsib_index(), emitsib_scale(), and encode_insn().


The documentation for this class was generated from the following files:
Generated on Fri May 7 21:16:11 2004 by doxygen 1.3.5