Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_flag.h>
#include <rz_core.h>
#include <rz_asm.h>
#include <rz_lib.h>
#include <rz_types.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
Classes | |
struct | operand_t |
struct | Opcode_t |
struct | lookup_t |
Typedefs | |
typedef enum tokentype_t | x86newTokenType |
typedef enum register_t | Register |
typedef struct operand_t | Operand |
typedef struct Opcode_t | Opcode |
typedef struct lookup_t | LookupTable |
Enumerations | |
enum | tokentype_t { TT_EOF , TT_WORD , TT_NUMBER , TT_SPECIAL } |
enum | register_t { X86R_UNDEFINED = -1 , X86R_EAX = 0 , X86R_ECX , X86R_EDX , X86R_EBX , X86R_ESP , X86R_EBP , X86R_ESI , X86R_EDI , X86R_EIP , X86R_AX = 0 , X86R_CX , X86R_DX , X86R_BX , X86R_SP , X86R_BP , X86R_SI , X86R_DI , X86R_AL = 0 , X86R_CL , X86R_DL , X86R_BL , X86R_AH , X86R_CH , X86R_DH , X86R_BH , X86R_RAX = 0 , X86R_RCX , X86R_RDX , X86R_RBX , X86R_RSP , X86R_RBP , X86R_RSI , X86R_RDI , X86R_RIP , X86R_R8 = 0 , X86R_R9 , X86R_R10 , X86R_R11 , X86R_R12 , X86R_R13 , X86R_R14 , X86R_R15 , X86R_CS = 0 , X86R_SS , X86R_DS , X86R_ES , X86R_FS , X86R_GS , X86R_CR0 = 0 , X86R_CR1 , X86R_CR2 , X86R_CR3 , X86R_CR4 , X86R_CR5 , X86R_CR6 , X86R_CR7 , X86R_DR0 = 0 , X86R_DR1 , X86R_DR2 , X86R_DR3 , X86R_DR4 , X86R_DR5 , X86R_DR6 , X86R_DR7 } |
Variables | |
const ut8 | SEG_REG_PREFIXES [] = { 0x26, 0x2e, 0x36, 0x3e, 0x64, 0x65 } |
LookupTable | oplookup [] |
RzAsmPlugin | rz_asm_plugin_x86_nz |
RZ_API RzLibStruct | rizin_plugin |
Definition at line 56 of file asm_x86_nz.c.
#define ENCODING_SHIFT 0 |
Definition at line 16 of file asm_x86_nz.c.
#define is_valid_registers | ( | op | ) |
Definition at line 79 of file asm_x86_nz.c.
#define MAX_OPERANDS 3 |
Definition at line 76 of file asm_x86_nz.c.
#define MAX_REPOP_LENGTH 20 |
Definition at line 77 of file asm_x86_nz.c.
#define OPSIZE_SHIFT 24 |
Definition at line 19 of file asm_x86_nz.c.
#define OPTYPE_SHIFT 6 |
Definition at line 17 of file asm_x86_nz.c.
#define OT_BYTE (1 << OPSIZE_SHIFT) |
Definition at line 49 of file asm_x86_nz.c.
#define OT_CONSTANT (1 << (OPTYPE_SHIFT + 1)) |
Definition at line 32 of file asm_x86_nz.c.
#define OT_CONTROLREG ((1 << (OPTYPE_SHIFT + 7)) | OT_REGALL) |
Definition at line 38 of file asm_x86_nz.c.
#define OT_DEBUGREG ((1 << (OPTYPE_SHIFT + 8)) | OT_REGALL) |
Definition at line 39 of file asm_x86_nz.c.
#define OT_DWORD (4 << OPSIZE_SHIFT) |
Definition at line 51 of file asm_x86_nz.c.
#define OT_FPUREG ((1 << (OPTYPE_SHIFT + 4)) | OT_REGALL) |
Definition at line 35 of file asm_x86_nz.c.
Definition at line 60 of file asm_x86_nz.c.
#define OT_GPREG ((1 << (OPTYPE_SHIFT + 2)) | OT_REGALL) |
Definition at line 33 of file asm_x86_nz.c.
#define OT_IMMEDIATE (1 << (ENCODING_SHIFT + 2)) |
Definition at line 24 of file asm_x86_nz.c.
#define OT_IMMOP (OT_CONSTANT | OT_IMMEDIATE) |
Definition at line 69 of file asm_x86_nz.c.
#define OT_JMPADDRESS (1 << (ENCODING_SHIFT + 3)) |
Definition at line 25 of file asm_x86_nz.c.
#define OT_MEMADDROP (OT_MEMORY | OT_IMMEDIATE) |
Definition at line 70 of file asm_x86_nz.c.
#define OT_MEMIMMOP (OT_MEMORY | OT_IMMEDIATE) |
Definition at line 67 of file asm_x86_nz.c.
Definition at line 66 of file asm_x86_nz.c.
#define OT_MEMORY (1 << (OPTYPE_SHIFT + 0)) |
Definition at line 31 of file asm_x86_nz.c.
#define OT_MMXREG ((1 << (OPTYPE_SHIFT + 5)) | OT_REGALL) |
Definition at line 36 of file asm_x86_nz.c.
#define OT_OWORD (16 << OPSIZE_SHIFT) |
Definition at line 53 of file asm_x86_nz.c.
#define OT_QWORD (8 << OPSIZE_SHIFT) |
Definition at line 52 of file asm_x86_nz.c.
#define OT_REG | ( | num | ) | ((1 << (REGMASK_SHIFT + (num))) | OT_REGTYPE) |
Definition at line 46 of file asm_x86_nz.c.
#define OT_REGALL (0xff << REGMASK_SHIFT) |
Definition at line 28 of file asm_x86_nz.c.
#define OT_REGMEM (1 << (ENCODING_SHIFT + 0)) |
Definition at line 22 of file asm_x86_nz.c.
Definition at line 64 of file asm_x86_nz.c.
Definition at line 65 of file asm_x86_nz.c.
#define OT_REGSPECOP | ( | type | ) | (OT_##type##REG | OT_SPECIAL) |
Definition at line 68 of file asm_x86_nz.c.
#define OT_REGTYPE ((OT_GPREG | OT_SEGMENTREG | OT_FPUREG | OT_MMXREG | OT_XMMREG | OT_CONTROLREG | OT_DEBUGREG) & ~OT_REGALL) |
Definition at line 43 of file asm_x86_nz.c.
#define OT_SEGMENTREG ((1 << (OPTYPE_SHIFT + 3)) | OT_REGALL) |
Definition at line 34 of file asm_x86_nz.c.
#define OT_SPECIAL (1 << (ENCODING_SHIFT + 1)) |
Definition at line 23 of file asm_x86_nz.c.
#define OT_SREG ((1 << (OPTYPE_SHIFT + 9)) | OT_REGALL) |
Definition at line 40 of file asm_x86_nz.c.
#define OT_TBYTE (32 << OPSIZE_SHIFT) |
Definition at line 54 of file asm_x86_nz.c.
#define OT_UNKNOWN (0 << OPSIZE_SHIFT) |
Definition at line 48 of file asm_x86_nz.c.
#define OT_WORD (2 << OPSIZE_SHIFT) |
Definition at line 50 of file asm_x86_nz.c.
#define OT_XMMREG ((1 << (OPTYPE_SHIFT + 6)) | OT_REGALL) |
Definition at line 37 of file asm_x86_nz.c.
Definition at line 61 of file asm_x86_nz.c.
#define REGMASK_SHIFT 16 |
Definition at line 18 of file asm_x86_nz.c.
#define SPECIAL_MASK 0x00000007 |
Definition at line 74 of file asm_x86_nz.c.
#define SPECIAL_SPEC 0x00010000 |
Definition at line 73 of file asm_x86_nz.c.
typedef struct lookup_t LookupTable |
typedef enum register_t Register |
typedef enum tokentype_t x86newTokenType |
enum register_t |
Definition at line 92 of file asm_x86_nz.c.
enum tokentype_t |
Enumerator | |
---|---|
TT_EOF | |
TT_WORD | |
TT_NUMBER | |
TT_SPECIAL |
Definition at line 85 of file asm_x86_nz.c.
Definition at line 5202 of file asm_x86_nz.c.
References a, free(), Opcode_t::has_bnd, i, Opcode_t::mnemonic, lookup_t::mnemonic, lookup_t::only_x32, op, lookup_t::opcode, lookup_t::opdo, oplookup, parseOpcode(), rz_asm_op_set_buf(), rz_str_casecmp(), lookup_t::size, cmd_descs_generate::str, and ut64().
Definition at line 714 of file asm_x86_nz.c.
References memcpy().
Definition at line 709 of file asm_x86_nz.c.
References memcpy().
Definition at line 5139 of file asm_x86_nz.c.
References a, rz_num_math(), and s.
Referenced by parse_segment_offset(), parseOperand(), and parseReg().
Definition at line 202 of file asm_x86_nz.c.
Referenced by opcmov(), opdec(), opinc(), opmov(), and process_1byte_op().
|
static |
Definition at line 4625 of file asm_x86_nz.c.
References test_evm::end, isalnum, isalpha, isdigit, isspace, cmd_descs_generate::str, TT_EOF, TT_NUMBER, TT_SPECIAL, and TT_WORD.
Referenced by parseOperand(), and parseReg().
Definition at line 198 of file asm_x86_nz.c.
References OT_CONTROLREG, OT_DEBUGREG, and OT_REGTYPE.
Referenced by opmov().
Definition at line 4666 of file asm_x86_nz.c.
References isdigit, n, and rz_str_ncasecmp().
Referenced by parseReg().
Definition at line 4687 of file asm_x86_nz.c.
References isdigit, n, and rz_str_ncasecmp().
Referenced by parseReg().
Definition at line 4657 of file asm_x86_nz.c.
References n, and rz_str_ncasecmp().
Referenced by parseReg().
Definition at line 561 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 574 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 587 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 806 of file asm_x86_nz.c.
References is_valid_registers, OT_DWORD, OT_QWORD, OT_REGALL, and X86R_UNDEFINED.
Definition at line 835 of file asm_x86_nz.c.
References a, is_valid_registers, mod(), OT_GPREG, OT_MEMORY, ut64(), and X86R_UNDEFINED.
Definition at line 1442 of file asm_x86_nz.c.
References is_valid_registers, OT_MEMORY, and ST8_MAX.
Definition at line 886 of file asm_x86_nz.c.
References getsib(), is_valid_registers, OT_CONSTANT, OT_MEMORY, OT_REGALL, ST8_MAX, X86R_EBP, and X86R_UNDEFINED.
Definition at line 600 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 1231 of file asm_x86_nz.c.
References is_valid_registers, OT_BYTE, OT_MEMORY, OT_QWORD, and OT_WORD.
Definition at line 3022 of file asm_x86_nz.c.
Definition at line 3215 of file asm_x86_nz.c.
Definition at line 3233 of file asm_x86_nz.c.
Definition at line 2881 of file asm_x86_nz.c.
Definition at line 3437 of file asm_x86_nz.c.
Definition at line 3520 of file asm_x86_nz.c.
Definition at line 2925 of file asm_x86_nz.c.
Definition at line 3044 of file asm_x86_nz.c.
Definition at line 3105 of file asm_x86_nz.c.
Definition at line 3129 of file asm_x86_nz.c.
Definition at line 3459 of file asm_x86_nz.c.
Definition at line 3542 of file asm_x86_nz.c.
Definition at line 3153 of file asm_x86_nz.c.
Definition at line 3625 of file asm_x86_nz.c.
Definition at line 3287 of file asm_x86_nz.c.
Definition at line 3311 of file asm_x86_nz.c.
Definition at line 3338 of file asm_x86_nz.c.
Definition at line 3708 of file asm_x86_nz.c.
Definition at line 3791 of file asm_x86_nz.c.
Definition at line 3180 of file asm_x86_nz.c.
Definition at line 3603 of file asm_x86_nz.c.
Definition at line 3900 of file asm_x86_nz.c.
Definition at line 3815 of file asm_x86_nz.c.
Definition at line 3852 of file asm_x86_nz.c.
Definition at line 3918 of file asm_x86_nz.c.
Definition at line 3833 of file asm_x86_nz.c.
Definition at line 3875 of file asm_x86_nz.c.
Definition at line 3686 of file asm_x86_nz.c.
Definition at line 3769 of file asm_x86_nz.c.
Definition at line 2980 of file asm_x86_nz.c.
Definition at line 3001 of file asm_x86_nz.c.
Definition at line 2959 of file asm_x86_nz.c.
Definition at line 1202 of file asm_x86_nz.c.
References is_valid_registers, OT_BYTE, OT_MEMORY, OT_QWORD, and OT_WORD.
Definition at line 1260 of file asm_x86_nz.c.
References a, is_valid_registers, OT_BYTE, OT_CONSTANT, OT_GPREG, OT_MEMORY, OT_QWORD, OT_WORD, RZ_LOG_ERROR, st64, UT32_MAX, and X86R_UNDEFINED.
Definition at line 1400 of file asm_x86_nz.c.
References is_valid_registers, OT_BYTE, OT_CONSTANT, OT_DWORD, OT_WORD, st32, X86R_AL, X86R_AX, X86R_DX, and X86R_EAX.
Definition at line 1761 of file asm_x86_nz.c.
References a, mod(), OT_CONSTANT, OT_MEMORY, OT_REGALL, reg, st32, ut64(), X86R_EBP, X86R_ESP, X86R_RIP, and X86R_UNDEFINED.
Definition at line 1826 of file asm_x86_nz.c.
Definition at line 3937 of file asm_x86_nz.c.
Definition at line 3959 of file asm_x86_nz.c.
Definition at line 2585 of file asm_x86_nz.c.
References a, delta, is_valid_registers, st8, and ut8.
Definition at line 1862 of file asm_x86_nz.c.
References a, ALL_SIZE, B0000, B0001, B0010, B0011, B0100, B0101, B0111, bits(), getsib(), is_debug_or_control(), mod(), OPSIZE_SHIFT, OT_BYTE, OT_CONSTANT, OT_DEBUGREG, OT_DWORD, OT_GPREG, OT_MEMORY, OT_QWORD, OT_REGALL, OT_REGTYPE, OT_SEGMENTREG, OT_WORD, reg, reg_bits(), SEG_REG_PREFIXES, st64, UT32_MAX, ut64(), X86R_BP, X86R_BX, X86R_DI, X86R_EAX, X86R_EBP, X86R_EIP, X86R_ESP, X86R_R8, X86R_RIP, X86R_SI, and X86R_UNDEFINED.
Definition at line 1015 of file asm_x86_nz.c.
References is_valid_registers, OT_MEMORY, OT_REGTYPE, OT_WORD, and X86R_ESP.
Definition at line 2393 of file asm_x86_nz.c.
References is_valid_registers, OT_BYTE, OT_MEMORY, OT_QWORD, and OT_WORD.
Definition at line 687 of file asm_x86_nz.c.
References is_valid_registers, OT_BYTE, OT_GPREG, OT_QWORD, and OT_WORD.
Definition at line 719 of file asm_x86_nz.c.
References ALL_SIZE, is_valid_registers, OT_QWORD, and X86R_UNDEFINED.
Definition at line 626 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 2545 of file asm_x86_nz.c.
References is_valid_registers, OT_BYTE, OT_CONSTANT, OT_DWORD, OT_WORD, st32, X86R_AL, X86R_AX, X86R_DX, and X86R_EAX.
Definition at line 2422 of file asm_x86_nz.c.
References a, is_valid_registers, mod(), OT_GPREG, OT_MEMORY, OT_REGTYPE, OT_SEGMENTREG, X86R_EBP, X86R_ESP, and X86R_FS.
Definition at line 2475 of file asm_x86_nz.c.
References a, is_valid_registers, mod(), OT_GPREG, OT_MEMORY, OT_REGTYPE, OT_SEGMENTREG, RZ_LOG_ERROR, st32, X86R_EBP, X86R_ESP, X86R_FS, and X86R_RIP.
Definition at line 5149 of file asm_x86_nz.c.
References a, free(), Opcode_t::has_bnd, i, Opcode_t::mnemonic, lookup_t::mnemonic, lookup_t::only_x32, lookup_t::opcode, lookup_t::opdo, oplookup, parseOpcode(), rz_str_casecmp(), lookup_t::size, and ut64().
Definition at line 752 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 2642 of file asm_x86_nz.c.
Definition at line 4096 of file asm_x86_nz.c.
Definition at line 4117 of file asm_x86_nz.c.
Definition at line 4035 of file asm_x86_nz.c.
Definition at line 4054 of file asm_x86_nz.c.
References OT_DWORD, OT_GPREG, OT_MEMORY, and OT_WORD.
Referenced by __disassemble(), asm_pic_disassemble(), disassemble(), do_analysis_search(), ds_atabs_option(), ds_disassemble(), mips_assemble(), print_rop(), rz_core_disasm_pdi_with_buf(), rz_parse_filter_dup(), rz_parse_immtrim(), and skipdata_opstr().
Definition at line 613 of file asm_x86_nz.c.
References a, is_al_reg(), OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), and process_group_1().
Definition at line 2708 of file asm_x86_nz.c.
References a, is_valid_registers, OT_BYTE, OT_CONSTANT, OT_DWORD, OT_MEMORY, OT_QWORD, OT_WORD, and RZ_LOG_ERROR.
Definition at line 4138 of file asm_x86_nz.c.
Definition at line 4160 of file asm_x86_nz.c.
Definition at line 4182 of file asm_x86_nz.c.
Definition at line 4202 of file asm_x86_nz.c.
Definition at line 4222 of file asm_x86_nz.c.
Definition at line 4241 of file asm_x86_nz.c.
Definition at line 639 of file asm_x86_nz.c.
References a, i, is_valid_registers, OT_BYTE, and OT_REGALL.
Definition at line 2774 of file asm_x86_nz.c.
References ALL_SIZE, is_valid_registers, OT_BYTE, OT_DWORD, OT_GPREG, OT_MEMORY, OT_QWORD, OT_WORD, reg, st32, ST8_MAX, and X86R_EAX.
Definition at line 664 of file asm_x86_nz.c.
References a, is_al_reg(), is_valid_registers, OT_CONSTANT, OT_GPREG, OT_WORD, process_16bit_group_1(), process_1byte_op(), process_group_1(), and X86R_UNDEFINED.
|
static |
Definition at line 4851 of file asm_x86_nz.c.
References a, c, getnum(), OT_MEMORY, p, pos, and cmd_descs_generate::str.
Referenced by parseOperand().
Definition at line 5095 of file asm_x86_nz.c.
References a, args, MAX_OPERANDS, out, parseOperand(), rz_str_ncasecmp(), rz_str_ndup(), strdup(), and X86R_UNDEFINED.
Referenced by assemble(), and oprep().
Definition at line 4876 of file asm_x86_nz.c.
References a, rz_core_t::flags, free(), getnum(), getToken(), last_type, malloc(), MAX_REPOP_LENGTH, NULL, OT_BYTE, OT_CONSTANT, OT_DWORD, OT_GPREG, OT_MEMORY, OT_OWORD, OT_QWORD, OT_REGTYPE, OT_SEGMENTREG, OT_TBYTE, OT_WORD, p, parse_segment_offset(), parseReg(), pos, read(), reg, rz_flag_get(), rz_str_ncasecmp(), st64, cmd_descs_generate::str, autogen_x86imm::tmp, TT_SPECIAL, TT_WORD, ut64(), and X86R_UNDEFINED.
Referenced by parseOpcode().
Get the register at position pos in str. Increase pos afterwards.
Definition at line 4711 of file asm_x86_nz.c.
References a, getnum(), getToken(), i, is_mm_register(), is_st_register(), is_xmm_register(), length, NULL, OT_BYTE, OT_CONTROLREG, OT_DEBUGREG, OT_DWORD, OT_FPUREG, OT_GPREG, OT_MMXREG, OT_QWORD, OT_REG, OT_REGALL, OT_REGTYPE, OT_SEGMENTREG, OT_WORD, OT_XMMREG, pos, reg, regs, RZ_LOG_ERROR, rz_str_ncasecmp(), cmd_descs_generate::str, TT_NUMBER, TT_SPECIAL, type, and X86R_UNDEFINED.
Referenced by parseOperand().
Definition at line 414 of file asm_x86_nz.c.
References a, getsib(), is_valid_registers, OT_BYTE, OT_CONSTANT, OT_DWORD, OT_MEMORY, OT_QWORD, OT_REGALL, reg, RZ_LOG_ERROR, st32, ST8_MAX, X86R_AL, X86R_EBP, X86R_ESP, and X86R_UNDEFINED.
Referenced by opadc(), opadd(), opand(), opcmp(), opor(), opsbb(), opsub(), and opxor().
Definition at line 246 of file asm_x86_nz.c.
References a, is_valid_registers, OT_BYTE, OT_DWORD, OT_MEMORY, OT_QWORD, RZ_LOG_ERROR, st32, ST8_MAX, X86R_EAX, X86R_EBP, and X86R_ESP.
Referenced by opadc(), opadd(), opand(), opcmp(), opor(), opsbb(), opsub(), and opxor().
Definition at line 340 of file asm_x86_nz.c.
References a, is_valid_registers, operand_t::offset, operand_t::offset_sign, OT_BYTE, OT_DWORD, OT_GPREG, OT_MEMORY, OT_QWORD, OT_WORD, operand_t::regs, RZ_LOG_ERROR, st32, and ut8.
LookupTable oplookup[] |
Definition at line 4268 of file asm_x86_nz.c.
Referenced by assemble(), and oprep().
RZ_API RzLibStruct rizin_plugin |
Definition at line 5260 of file asm_x86_nz.c.
RzAsmPlugin rz_asm_plugin_x86_nz |
Definition at line 5249 of file asm_x86_nz.c.
Definition at line 83 of file asm_x86_nz.c.
Referenced by opmov().