[Lua] 纯文本查看 复制代码
-- =============================================================================
-- ASM_Translator.lua - Cheat Engine 汇编指令中文翻译器
-- =============================================================================
-- 功能:将 CE 反汇编视图中的英文指令描述实时翻译为中文
-- 作者:重构版本
-- =============================================================================
-- 性能优化:缓存常用函数
local string_find = string.find
local string_match = string.match
local string_gsub = string.gsub
local string_lower = string.lower
local math_floor = math.floor
local pairs = pairs
local ipairs = ipairs
local pcall = pcall
-- =============================================================================
-- 1. 翻译数据表
-- =============================================================================
local OpcodesTab = {
-- ========== 基础指令 ==========
["no operation"] = "nop:空指令",
["halt"] = "hlt:处理器停机",
-- ========== 调用与返回 ==========
["call procedure"] = "call:调用函数",
["call to interrupt procedure"] = "int:触发中断",
["call to interrupt procedure%-3:trap to debugger"] = "int 3:断点中断",
["call to interrupt procedure%-4:if overflow flag=1"] = "into:溢出则中断 (OF=1)",
["near return to calling procedure"] = "ret:函数返回 (近)",
["far return to calling procedure"] = "retf:函数返回 (远)",
["interrupt return"] = "iret:中断返回",
["high level procedure exit"] = "leave:清理堆栈帧",
-- ========== 堆栈操作 ==========
["push word or doubleword onto the stack"] = "push:数据入栈",
["push byte onto the stack"] = "push:单字节入栈",
["push word or doubleword onto the stack %(sign extended%)"] = "push:入栈 (符号扩展)",
["pop a value from the stack"] = "pop:弹出数据",
["push all general%-purpose registers"] = "pushad:压入所有寄存器",
["push all general%-purpose registers %(invalid%) %(invalid%)"] = "pushad:压入所有寄存器 (64位无效)",
["pop all general%-purpose registers"] = "popad:弹出所有寄存器",
["pop all general%-purpose registers %(invalid%)"] = "popad:弹出所有寄存器 (64位无效)",
["push eflags register onto the stack"] = "pushfd:压入标志寄存器",
["pop stack into eflags register"] = "popfd:弹出到标志寄存器",
["place cs on the stack"] = "push cs:压入 CS",
["place ds on the stack"] = "push ds:压入 DS",
["place es on the stack"] = "push es:压入 ES",
["place ss on the stack"] = "push ss:压入 SS",
["remove ds from the stack"] = "pop ds:弹出到 DS",
["remove es from the stack"] = "pop es:弹出到 ES",
["remove ss from the stack"] = "pop ss:弹出到 SS",
["make stack frame for procedure parameters"] = "enter:建立堆栈帧",
-- ========== 数据传送 ==========
["copy memory"] = "mov:数据传送",
["Move with zero%-extend"] = "movzx:零扩展传送",
["move with sign%-extension"] = "movsx:符号扩展传送",
["Move doubleword to quadword with signextension"] = "movsxd:双字符号扩展为四字",
["Move data after swapping bytes"] = "movbe:字节序交换传送",
["load effective address"] = "lea:加载有效地址",
["exchange memory with register"] = "xchg:交换 (内存/寄存器)",
["exchange register with register"] = "xchg:交换寄存器",
["Exchange"] = "xchg:交换数据",
["Exchange RAX with register"] = "xchg:交换 RAX",
-- ========== 算术运算 ==========
["Add"] = "add:加法",
["add"] = "fadd:浮点加法",
["add %(sign extended%)"] = "add:加法 (符号扩展)",
["add with carry"] = "adc:带进位加法",
["add with carry %(sign extended%)"] = "adc:带进位加法 (符号扩展)",
["subtract"] = "sub:减法",
["substract"] = "fsub:浮点减法",
["integer subtraction with borrow"] = "sbb:带借位减法",
["integer subtraction with borrow %(sign extended%)"] = "sbb:带借位减法 (符号扩展)",
["increment by 1"] = "inc:自增",
["decrement by 1"] = "dec:自减",
["two's complement negation"] = "neg:取负",
["unsigned multiply"] = "mul:无符号乘法",
["signed multiply"] = "imul:有符号乘法",
["unsigned divide"] = "div:无符号除法",
["signed divide"] = "idiv:有符号除法",
["multiply"] = "fmul:浮点乘法",
["divide"] = "fdiv:浮点除法",
["add and pop"] = "faddp:浮点加法并出栈",
["subtract and pop from stack"] = "fsubp:浮点减法并出栈",
["reverse subtract"] = "fsubr:浮点反向减法",
["reverse substract"] = "fsubr:浮点反向减法",
["reverse divide"] = "fdivrp:浮点反向除法并出栈",
-- ========== 逻辑运算 ==========
["logical and"] = "and:按位与",
["logical and %(sign extended%)"] = "and:按位与 (符号扩展)",
["logical inclusive or"] = "or:按位或",
["logical inclusive or %(sign%-extended%)"] = "or:按位或 (符号扩展)",
["logical exclusive or"] = "xor:按位异或",
["one's complement negation"] = "not:按位取反",
["logical and not"] = "pandn:按位与非",
["bitwise logical or"] = "por:按位或",
-- ========== 位操作 ==========
["bit test"] = "bt:位测试",
["bit test and set"] = "bts:位测试并置1",
["bit test and reset"] = "btr:位测试并清0",
["bit test and complement"] = "btc:位测试并取反",
["bit scan forward"] = "bsf:正向位扫描",
["bit scan reverse"] = "bsr:反向位扫描",
["byte swap"] = "bswap:字节序交换",
["double precision shift left"] = "shld:双精度左移",
["double precision shift right"] = "shrd:双精度右移",
["Bit field extract"] = "bextr:位域提取 (BMI1)",
["Extract lowest set isolated bit"] = "blsi:提取最低置位 (BMI1)",
["Reset lowerst set bit"] = "blsr:清除最低置位 (BMI1)",
["Get mask up to lowest set bit"] = "blsmsk:获取最低置位掩码",
["Zero high bits starting with specified bit position"] = "bzhi:清除高位",
["Parallel bits deposit"] = "pdep:并行位分配 (BMI2)",
["count the number of trailing zero bits"] = "tzcnt:计算尾部零位数",
["count the number of leading zero bits"] = "lzcnt:计算前导零位数",
["Return the Count of Number of Bits Set to 1"] = "popcnt:计算置1位数",
-- ========== 比较与测试 ==========
["compare two operands"] = "cmp:比较",
["logical compare"] = "test:逻辑测试",
["Logical compare"] = "ptest:打包数据测试",
["Packed bit test"] = "ptest:打包位测试",
["check array index against bounds"] = "bound:数组越界检查",
["test"] = "ftst:浮点测试",
-- ========== 串操作 ==========
["move data from string to string"] = "movs:串传送",
["store string"] = "stos:串存储",
["load string"] = "lods:串加载",
["scan string"] = "scas:扫描字符串",
["compare al with byte at es:edi and set status flag"] = "scasb:字符串扫描",
["compare string operands"] = "cmps:比较字符串",
-- ========== 类型转换 ==========
["convert byte to word"] = "cbw:字节扩展为字",
["convert word to doubleword"] = "cwde:字扩展为双字",
["convert doubleword to quadword"] = "cdq:双字扩展为四字",
["convert quadword to octword"] = "cqo:四字扩展为八字",
-- ========== 跳转指令 ==========
["jump short"] = "jmp:短跳转",
["jump near"] = "jmp:近跳转",
["jump far"] = "jmp far:远跳转",
["jump short if equal %(ZF=1%)"] = "je/jz:相等则跳转",
["jump near if equal %(ZF=1%)"] = "je/jz:相等则跳转 (近)",
["jump short if not equal %(ZF=0%)"] = "jne/jnz:不相等则跳转",
["jump near if not equal %(ZF=0%)"] = "jne/jnz:不相等则跳转 (近)",
["jump short if above %(ZF=0 and CF=0%)"] = "ja:高于则跳转 (无符号>)",
["jump near if above %(CF=0 and ZF=0%)"] = "ja:高于则跳转 (近)",
["jump short if above or equal %(CF=0%)"] = "jae:高于等于则跳转",
["jump near if above or equal %(CF=0%)"] = "jae:高于等于则跳转 (近)",
["jump short if below/carry %(CF=1%)"] = "jb/jc:低于则跳转 (无符号<)",
["jump near if below/carry %(CF=1%)"] = "jb/jc:低于则跳转 (近)",
["jump short if not above %(ZF=1 or CF=1%)"] = "jbe:低于等于则跳转",
["jump near if below or equal %(CF=1 or ZF=1%)"] = "jbe:低于等于则跳转 (近)",
["jump short if greater %(ZF=0 or SF=OF%)"] = "jg:大于则跳转 (有符号>)",
["jump near if greater %(ZF=0 and SF=OF%)"] = "jg:大于则跳转 (近)",
["jump short if not less %(greater or equal%) %(SF=OF%)"] = "jge:大于等于则跳转",
["jump near if not less %(SF=OF%)"] = "jge:大于等于则跳转 (近)",
["jump short if not greater or equal %(SF~=OF%)"] = "jl:小于则跳转 (有符号<)",
["jump near if less %(SF~=OF%)"] = "jl:小于则跳转 (近)",
["jump short if less or equal %(ZF=1 or SF~=OF%)"] = "jle:小于等于则跳转",
["jump near if not greater %(ZF=1 or SF~=OF%)"] = "jle:小于等于则跳转 (近)",
["jump short if sign %(SF=1%)"] = "js:负数则跳转",
["jump near if sign %(SF=1%)"] = "js:负数则跳转 (近)",
["jump short if not sign %(SF=0%)"] = "jns:正数则跳转",
["jump near if not sign %(SF=0%)"] = "jns:正数则跳转 (近)",
["jump short if overflow %(OF=1%)"] = "jo:溢出则跳转",
["jump near if overflow %(OF=1%)"] = "jo:溢出则跳转 (近)",
["jump short if not overflow %(OF=0%)"] = "jno:未溢出则跳转",
["jump near if not overflow %(OF=0%)"] = "jno:未溢出则跳转 (近)",
["jump short if parity %(PF=1%)"] = "jp:偶校验则跳转",
["jump near if parity %(PF=1%)"] = "jp:偶校验则跳转 (近)",
["jump short if not parity %(PF=0%)"] = "jnp:奇校验则跳转",
["jump near if not parity %(PF=0%)"] = "jnp:奇校验则跳转 (近)",
["jump short if cx=0"] = "jcxz:CX为0则跳转",
-- ========== 循环指令 ==========
["loop according to ecx counting"] = "loop:循环 (ECX-1)",
["loop according to ecx counter"] = "loope/loopz:相等则循环",
-- ========== 条件设置 (SETcc) ==========
["set byte if equal"] = "sete/setz:相等则置1",
["set byte if not equal"] = "setne/setnz:不相等则置1",
["set byte if above"] = "seta:高于则置1",
["set byte if above or equal"] = "setae:高于等于则置1",
["set byte if below/carry"] = "setb/setc:低于则置1",
["set byte if below or equal"] = "setbe:低于等于则置1",
["set byte if greater"] = "setg:大于则置1",
["set byte if greater or equal"] = "setge:大于等于则置1",
["set byte if less"] = "setl:小于则置1",
["set byte if less or equal"] = "setle:小于等于则置1",
["set byte if sign"] = "sets:负数则置1",
["set byte if not sign"] = "setns:正数则置1",
["set byte if overflow"] = "seto:溢出则置1",
["set byte if not overfloww"] = "setno:未溢出则置1",
["set byte if parity"] = "setp:偶校验则置1",
["set byte if not parity"] = "setnp:奇校验则置1",
-- ========== 条件传送 (CMOVcc) ==========
["move if equal/move if zero"] = "cmove/cmovz:相等则传送",
["move if not equal/move if not zero"] = "cmovne/cmovnz:不相等则传送",
["move if above"] = "cmova:高于则传送",
["move if above or equal/ move if not carry"] = "cmovae:高于等于则传送",
["move if below/ move if carry"] = "cmovb/cmovc:低于则传送",
["move if below or equal"] = "cmovbe:低于等于则传送",
["move if greater"] = "cmovg:大于则传送",
["move if greater or equal"] = "cmovge:大于等于则传送",
["move if less"] = "cmovl:小于则传送",
["move if less or equal"] = "cmovle:小于等于则传送",
["move if sign"] = "cmovs:负数则传送",
["move if not sign"] = "cmovns:正数则传送",
["move if overflow"] = "cmovo:溢出则传送",
["move if not overflow"] = "cmovno:未溢出则传送",
["move if parity even"] = "cmovp:偶校验则传送",
["move if not parity/move if parity odd"] = "cmovnp:奇校验则传送",
-- ========== 标志位操作 ==========
["set carry flag"] = "stc:置进位标志",
["clear carry flag"] = "clc:清进位标志",
["complement carry flag"] = "cmc:翻转进位标志",
["set direction flag"] = "std:置方向标志",
["clear direction flag"] = "cld:清方向标志",
["set interrupt flag"] = "sti:允许中断",
["clear interrupt flag"] = "cli:禁止中断",
["load status flag into ah register"] = "lahf:标志位加载到AH",
["store ah into flags"] = "sahf:AH写入标志位",
-- ========== FPU 加载/存储 ==========
["load floating point value"] = "fld:加载浮点数",
["push st%(i%) onto the fpu register stack"] = "fld:复制ST(i)到栈顶",
["load integer"] = "fild:加载整数转浮点",
["store real"] = "fst:存储浮点数",
["store single"] = "fst:存储单精度",
["store double"] = "fst:存储双精度",
["store extended"] = "fstp:存储扩展精度并出栈",
["store integer"] = "fist:存储为整数",
["store integer with truncation"] = "fisttp:截断存储为整数",
["store bcd integer and pop"] = "fbstp:存储BCD并出栈",
["load binary coded decimal"] = "fbld:加载BCD码",
["exchange register contents"] = "fxch:交换FPU寄存器",
-- ========== FPU 数学运算 ==========
["change sign"] = "fchs:符号取反",
["absolute value"] = "fabs:取绝对值",
["square root"] = "fsqrt:平方根",
["partial tangent"] = "fptan:正切",
["partial arctangent"] = "fpatan:反正切",
["sine"] = "fsin:正弦",
["cosine"] = "fcos:余弦",
["sine and cosine"] = "fsincos:正弦和余弦",
["compute 2^x%-1"] = "f2xm1:计算 2^x-1",
["compute y%*log%(2%)x"] = "fyl2x:计算 y×log₂(x)",
["compute y%*log%(2%)%(x%+1%)"] = "fyl2xp1:计算 y×log₂(x+1)",
["compute y%*log%(2%)x"] = "fyl2x:计算 y×log₂(x)",
["compute y%*log%(2%)%(x%+1%)"] = "fyl2xp1:计算 y×log₂(x+1)",
["round to integer"] = "frndint:舍入为整数",
["scale"] = "fscale:比例缩放",
["partial remainder"] = "fprem:部分余数",
["extract exponent and significand"] = "fxtract:提取指数和尾数",
-- ========== FPU 比较 ==========
["compare real"] = "fcom:浮点比较",
["compare real and pop register stack"] = "fcomp:浮点比较并出栈",
["compare real and pop register stack twice"] = "fcompp:浮点比较并出栈两次",
["compare integer"] = "ficom:浮点与整数比较",
["unordered compare real"] = "fucom:无序浮点比较",
["floating%-point: compare real and set eflags"] = "fcomi:浮点比较设置EFLAGS",
["compare real and set eflags"] = "fcomip:浮点比较设置EFLAGS并出栈",
["examine"] = "fxam:检查ST(0)类型",
-- ========== FPU 控制 ==========
["store status word"] = "fstsw:存储状态字",
["store control word"] = "fstcw:存储控制字",
["load control word"] = "fldcw:加载控制字",
["store fpu environment"] = "fstenv:保存FPU环境",
["load fpu environment"] = "fldenv:加载FPU环境",
["store fpu state"] = "fsave:保存FPU状态",
["restore fpu state"] = "frstor:恢复FPU状态",
["initialize floating%-point unit"] = "finit:初始化FPU",
["initialize floaring%-point unit"] = "finit:初始化FPU",
["clear exceptions"] = "fclex:清除浮点异常",
["wait"] = "fwait:等待FPU完成",
-- ========== FPU 常量 ==========
["Push %+0%.0 onto the FPU register stack"] = "fldz:加载 0.0",
["Push %+1%.0 onto the FPU register stack"] = "fld1:加载 1.0",
["Push \"pi\" onto the FPU register stackload constant"] = "fldpi:加载 π",
["push \"pi\" onto the fpu register stackload constant"] = "fldpi:加载 π",
["Push log2%(e%) onto the FPU register stack"] = "fldl2e:加载 log₂(e)",
["Push log2%(10%) onto the FPU register stack"] = "fldl2t:加载 log₂(10)",
["Push log e%(2%) onto the FPU register stack"] = "fldln2:加载 ln(2)",
["Push log10%(2%) onto the FPU register stack"] = "fldlg2:加载 log₁₀(2)",
["one"] = "fld1:加载 1.0",
["two"] = "fld:加载常量",
["decrement stack%-top pointer"] = "fdecstp:栈顶指针减1",
["increment stack%-top pointer"] = "fincstp:栈顶指针加1",
["free floating%-point register"] = "ffree:释放FPU寄存器",
["free floating%-point register and pop %(might not work%)"] = "ffreep:释放FPU寄存器并出栈",
-- ========== FPU 条件移动 ==========
["floating%-point: move if below"] = "fcmovb:低于则浮点传送",
["floating%-point: move if below or equal"] = "fcmovbe:低于等于则浮点传送",
["floating%-point: move if equal"] = "fcmove:相等则浮点传送",
["floating%-point: move if not below"] = "fcmovnb:不低于则浮点传送",
["floating%-point: move if not below or equal"] = "fcmovnbe:不低于等于则浮点传送",
["floating%-point: move if not equal"] = "fcmovne:不相等则浮点传送",
["floating%-point: move if not unordered"] = "fcmovnu:有序则浮点传送",
["floating%-point: move if unordered"] = "fcmovu:无序则浮点传送",
-- ========== MMX ==========
["empty mmx™ state"] = "emms:清空MMX状态",
["move 64 bits"] = "movq:传送64位",
["move 64 bits non temporal"] = "movnti:64位非临时传送",
["move 32 bits"] = "movd:传送32位",
["move doubleword"] = "movd:传送双字",
["move quadword"] = "movq:传送四字",
-- ========== SSE/AVX 数据传送 ==========
["move aligned four packed single%-fp"] = "movaps:对齐传送打包单精度",
["move unaligned four packed single%-fp"] = "movups:未对齐传送打包单精度",
["move scalar single%-fp"] = "movss:传送标量单精度",
["move scalar double%-fp"] = "movsd:传送标量双精度",
["move aligned double quadword"] = "movdqa:对齐传送双四字",
["move unaligned double quadword"] = "movdqu:未对齐传送双四字",
["move aligned packed double%-fp values"] = "movapd:对齐传送打包双精度",
["move unaligned packed double%-fp"] = "movupd:未对齐传送打包双精度",
["move low packed single%-fp"] = "movlps:传送低位打包单精度",
["move low packed double%-fp"] = "movlpd:传送低位打包双精度",
["move low packed double%-precision floating%-point value"] = "movlpd:传送低位双精度",
["move high packed double%-precision floating%-point value"] = "movhpd:传送高位双精度",
["high to low packed single%-fp"] = "movhlps:高位到低位单精度",
["move one double%-fp and duplicate"] = "movddup:双精度复制传送",
["move packed single%-fp high and duplicate"] = "movshdup:单精度高位复制",
["move packed single%-fp Low and duplicate"] = "movsldup:单精度低位复制",
["move low quadword from xmm to mmx technology register"] = "movdq2q:XMM到MMX",
["move quadword from mmx technology to xmm register"] = "movq2dq:MMX到XMM",
-- ========== SSE/AVX 混洗 ==========
["shuffle single%-fp"] = "shufps:单精度混洗",
["shuffle double%-fp"] = "shufpd:双精度混洗",
["packed shuffle doubleword"] = "pshufd:打包双字混洗",
["shuffle packed high words"] = "pshufhw:打包高位字混洗",
["shuffle packed low words"] = "pshuflw:打包低位字混洗",
["packed shuffle word"] = "pshufw:打包字混洗",
["Packed shuffle bytes"] = "pshufb:打包字节混洗",
["unpack low packed single%-fp"] = "unpcklps:解包低位单精度",
["unpack high packed single%-fp"] = "unpckhps:解包高位单精度",
["unpack low packed data"] = "punpckl:解包低位数据",
["unpack high packed data"] = "punpckh:解包高位数据",
["unpack and interleave high packed double%-fp"] = "unpckhpd:解包高位双精度",
["Packed align right"] = "palignr:打包右对齐",
-- ========== SSE/AVX 算术 ==========
["add packed sp fp numbers from xmm2/mem to xmm1"] = "addps:打包单精度加法",
["add the lower sp fp number from xmm2/mem to xmm1%."] = "addss:标量单精度加法",
["add packed double%-precision floating%-point values from xmm2/mem to xmm1"] = "addpd:打包双精度加法",
["packed single%-fp subtract"] = "subps:打包单精度减法",
["scalar single%-fp subtract"] = "subss:标量单精度减法",
["packed double%-fp subtract"] = "subpd:打包双精度减法",
["scalar double%-fp subtract"] = "subsd:标量双精度减法",
["packed single%-fp multiply"] = "mulps:打包单精度乘法",
["scalar single%-fp multiply"] = "mulss:标量单精度乘法",
["packed double%-fp multiply"] = "mulpd:打包双精度乘法",
["scalar double%-fp multiply"] = "mulsd:标量双精度乘法",
["packed single%-fp divide"] = "divps:打包单精度除法",
["scalar single%-fp divide"] = "divss:标量单精度除法",
["packed double%-fp divide"] = "divpd:打包双精度除法",
["scalar double%-precision%-fp divide"] = "divsd:标量双精度除法",
["packed double%-precision fp divide"] = "divpd:打包双精度除法",
["packed single%-fp square root"] = "sqrtps:打包单精度平方根",
["scalar single%-fp square root"] = "sqrtss:标量单精度平方根",
["packed double%-fp square root"] = "sqrtpd:打包双精度平方根",
["scalar double%-fp square root"] = "sqrtsd:标量双精度平方根",
["packed single%-fp square root reciprocal"] = "rsqrtps:打包单精度平方根倒数",
["scalar single%-fp square root reciprocal"] = "rsqrtss:标量单精度平方根倒数",
["Compute Reciprocal of Scalar Single%-Precision Floating%-Point Values"] = "rcpss:标量单精度倒数",
["Compute Reciprocals of Packed Single%-Precision Floating%-Point Values"] = "rcpps:打包单精度倒数",
["packed single%-fp maximum"] = "maxps:打包单精度最大值",
["scalar single%-fp maximum"] = "maxss:标量单精度最大值",
["packed double%-fp maximum"] = "maxpd:打包双精度最大值",
["scalar double%-fp maximum"] = "maxsd:标量双精度最大值",
["packed single%-fp minimum"] = "minps:打包单精度最小值",
["scalar single%-fp minimum"] = "minss:标量单精度最小值",
["packed double%-fp minimum"] = "minpd:打包双精度最小值",
["scalar double%-fp minimum"] = "minsd:标量双精度最小值",
["packed single%-fp horizontal add"] = "haddps:打包单精度水平加法",
["packed double%-fp horizontal add"] = "haddpd:打包双精度水平加法",
["packed single%-fp horizontal subtract"] = "hsubps:打包单精度水平减法",
["packed double%-fp horizontal subtract"] = "hsubpd:打包双精度水平减法",
["Packed Single%-FP Add/Subtract"] = "addsubps:打包单精度加减交替",
["Packed Double%-FP Add/Subtract"] = "addsubpd:打包双精度加减交替",
["Dot product of packed single precision floating%-point values"] = "dpps:单精度点积",
["Dot product of packed double precision floating%-point values"] = "dppd:双精度点积",
-- ========== SSE/AVX 比较 ==========
["packed single%-fp compare"] = "cmpps:打包单精度比较",
["compare packed double%-precision floating%-point values"] = "cmppd:打包双精度比较",
["compare scalar double%-precision floating%-point values"] = "cmpsd:标量双精度比较",
["compare scalar single%-fp"] = "cmpss:标量单精度比较",
["scalar ordered single%-fp compare and set eflags"] = "comiss:标量单精度比较设置EFLAGS",
["unordered scalar single%-fp compare and set eflags"] = "ucomiss:无序标量单精度比较",
["compare scalar ordered double%-precision floating point values and set eflags"] = "comisd:标量双精度比较设置EFLAGS",
["unordered scalar double%-fp compare and set eflags"] = "ucomisd:无序标量双精度比较",
["packed compare for equal"] = "pcmpeq:打包相等比较",
["Packed compare for equal"] = "pcmpeq:打包相等比较",
["packed compare for greater than"] = "pcmpgt:打包大于比较",
["Compare packed qword data for equal"] = "pcmpeqq:打包四字相等比较",
["Compare packed data for greater than"] = "pcmpgtq:打包四字大于比较",
["Packed compare explicit length string, return mask"] = "pcmpestrm:显式长度串比较返回掩码",
["Packed compare explicit length string, return index"] = "pcmpestri:显式长度串比较返回索引",
["Packed compare implicit length string, return mask"] = "pcmpistrm:隐式长度串比较返回掩码",
["Packed compare implicit length string, return index"] = "pcmpistri:隐式长度串比较返回索引",
-- ========== SSE/AVX 逻辑 ==========
["bit%-wise logical and of xmm2/m128 and xmm1"] = "pand:打包逻辑与",
["bit%-wise logical and for single fp"] = "andps:单精度逻辑与",
["bit%-wise logical and not for single%-fp"] = "andnps:单精度逻辑与非",
["bit%-wise logical and not of packed double%-precision fp values"] = "andnpd:双精度逻辑与非",
["bit%-wise logical or for single%-fp"] = "orps:单精度逻辑或",
["bit%-wise logical or of double%-fp"] = "orpd:双精度逻辑或",
["bit%-wise logical xor for single%-fp data"] = "xorps:单精度逻辑异或",
["bit%-wise logical xor for double%-fp data"] = "xorpd:双精度逻辑异或",
-- ========== SSE/AVX 打包整数 ==========
["packed add"] = "padd:打包加法",
["packed add with saturation"] = "padds:饱和打包加法",
["packed add unsigned with saturation"] = "paddus:无符号饱和加法",
["add packed quadword integers"] = "paddq:打包四字加法",
["packed subtract"] = "psub:打包减法",
["packed subtract with saturation"] = "psubs:饱和打包减法",
["packed subtract unsigned with saturation"] = "psubus:无符号饱和减法",
["Multiple packed signed dword integers"] = "pmulld:打包有符号双字乘法",
["Multiply Packed Signed Dword Integers and Store Low Result"] = "pmulld:打包有符号双字乘法",
["packed multiply low"] = "pmullw:打包字乘法低位",
["packed multiply high"] = "pmulhw:打包字乘法高位",
["multiply packed unsigned doubleword integers"] = "pmuludq:打包无符号双字乘法",
["packed multiply high unsigned"] = "pmulhuw:打包无符号字乘法高位",
["packed multiply and add"] = "pmaddwd:打包乘加",
["Multiply and add signed and unsigned bytes"] = "pmaddubsw:有符号无符号字节乘加",
["Packed multiply high with round and scale"] = "pmulhrsw:打包乘高位舍入缩放",
["packed shift left logical"] = "psll:打包逻辑左移",
["packed shift right logical"] = "psrl:打包逻辑右移",
["packed shift right arithmetic"] = "psra:打包算术右移",
["shift packed data right arithmetic"] = "psrad:打包双字算术右移",
["shift double quadword left logical"] = "pslldq:双四字逻辑左移",
["shift double quadword right logical"] = "psrldq:双四字逻辑右移",
["Packed absolute value"] = "pabs:打包绝对值",
["Packed horizontal add"] = "phadd:打包水平加法",
["Packed horizontal add and saturate"] = "phaddsw:打包水平饱和加法",
["Packed horizontal subtract"] = "phsub:打包水平减法",
["Packed SIGN"] = "psign:打包符号运算",
["packed average"] = "pavg:打包平均值",
["packed sum of absolute differences"] = "psadbw:打包绝对差值之和",
["Compute multiple packed sums of absolute difference"] = "mpsadbw:多重绝对差值之和",
["Packed horitontal word minimum"] = "phminposuw:打包水平字最小值位置",
["packed unsigned integer byte minimum"] = "pminub:无符号打包字节最小值",
["packed unsigned integer byte maximum"] = "pmaxub:无符号打包字节最大值",
["packed signed integer word minimum"] = "pminsw:有符号打包字最小值",
["packed signed integer word maximum"] = "pmaxsw:有符号打包字最大值",
["Maximum of packed word integers"] = "pmaxsw:有符号打包字最大值",
["Maximum of packed signed byte integers"] = "pmaxsb:有符号打包字节最大值",
["Maximum of packed signed dword integers"] = "pmaxsd:有符号打包双字最大值",
["Maximum of packed unsigned dword integers"] = "pmaxud:无符号打包双字最大值",
["Minimum of packed signed byte integers"] = "pminsb:有符号打包字节最小值",
["Minimum of packed dword integers"] = "pminsd:有符号打包双字最小值",
["Minimum of packed word integers"] = "pminuw:无符号打包字最小值",
["pack with signed saturation"] = "packss:有符号饱和打包",
["pack with unsigned saturation"] = "packus:无符号饱和打包",
["Pack with unsigned saturation"] = "packusdw:无符号饱和打包",
["Packed move with sign extend"] = "pmovsx:打包符号扩展传送",
["Packed move with zero extend"] = "pmovzx:打包零扩展传送",
-- ========== SSE/AVX 插入/提取 ==========
["Insert dword"] = "pinsrd:插入双字",
["Insert Byte"] = "pinsrb:插入字节",
["insert word"] = "pinsrw:插入字",
["Insert qword"] = "pinsrq:插入四字",
["Insert Scalar Single%-Precision Floating%-Point Value"] = "insertps:插入标量单精度",
["Insert packed floating%-point values"] = "vinsertf128:插入打包浮点数",
["Insert packed integer values"] = "vinserti128:插入打包整数",
["Extract byte"] = "pextrb:提取字节",
["Extract word"] = "pextrw:提取字",
["extract word"] = "pextrw:提取字",
["Extract dword"] = "pextrd:提取双字",
["Extract qword"] = "pextrq:提取四字",
["Extract packed single precision floating%-point value"] = "extractps:提取单精度",
["Extract packed floating%-point values"] = "vextractf128:提取打包浮点数",
["Extract packed integer values"] = "vextracti128:提取打包整数",
["move mask to integer"] = "movmskps:提取单精度符号掩码",
["move byte mask to integer"] = "pmovmskb:提取字节符号掩码",
["extract packed double%-precision floating%-point sign mask"] = "movmskpd:提取双精度符号掩码",
-- ========== SSE/AVX 转换 ==========
["scalar signed int32 to single%-fp conversion"] = "cvtsi2ss:整数转标量单精度",
["scalar single%-fp to signed int32 conversion"] = "cvtss2si:标量单精度转整数",
["scalar single%-fp to signed int32 conversion %(truncate%)"] = "cvttss2si:标量单精度截断转整数",
["convert doubleword integer to scalar doubleprecision floating%-point value"] = "cvtsi2sd:整数转标量双精度",
["convert scalar double%-precision floating%-point value to doubleword integer"] = "cvtsd2si:标量双精度转整数",
["convert with truncation scalar double%-precision floating point value to signed doubleword integer"] = "cvttsd2si:标量双精度截断转整数",
["convert scalar single%-precision floating%-point value to scalar double%-precision floating%-point value"] = "cvtss2sd:标量单精度转双精度",
["convert scalar double%-precision floating%-point value to scalar single%-precision floating%-point value"] = "cvtsd2ss:标量双精度转单精度",
["packed single%-fp to packed int32 conversion"] = "cvtps2dq:打包单精度转整数",
["packed single%-fp to packed int32 conversion %(truncate%)"] = "cvttps2dq:打包单精度截断转整数",
["Convert with Truncation Packed Single%-Precision FP Values to Packed Dword Integers"] = "cvttps2dq:打包单精度截断转整数",
["convert packed double precision fp values to packed single precision fp values"] = "cvtpd2ps:打包双精度转单精度",
["convert packed single precision fp values to packed double precision fp values"] = "cvtps2pd:打包单精度转双精度",
["convert two packed signed dwords from param2 to two packed dp%-floating point values in param1"] = "cvtdq2pd:打包整数转双精度",
["convert ps%-precision fpoint values to packed dword's "] = "cvtps2dq:打包单精度转整数",
["convert ps%-precision fpoint values to packed dword"] = "cvtps2dq:打包单精度转整数",
["convert 2 packed dp%-fp's from param 2 to packed signed dword in param1"] = "cvtpd2dq:打包双精度转整数",
["convert 2 packed dp%-fp"] = "cvtpd2dq:打包双精度转整数",
["convert with truncation packed double%-precision floating%-point values to packed doubleword integers"] = "cvttpd2dq:打包双精度截断转整数",
["packed doubleprecision%-fp to packed dword conversion %(truncate%)"] = "cvttpd2dq:打包双精度截断转整数",
["convert packed dword's to ps%-precision fpoint values"] = "cvtdq2ps:打包整数转单精度",
["convert packed dword"] = "cvtdq2ps:打包整数转单精度",
["packed signed int32 to packed single%-fp conversion"] = "cvtdq2ps:打包整数转单精度",
["Convert 16%-bit FP values to single%-precision FP values"] = "vcvtph2ps:16位浮点转单精度",
["Convert single%-precision FP value to 16%-bit FP value"] = "vcvtps2ph:单精度转16位浮点",
-- ========== SSE/AVX 混合/置换 ==========
["Blend packed double precision floating%-point values"] = "blendpd:混合打包双精度",
["Blend packed single precision floating%-point values"] = "blendps:混合打包单精度",
["Blend packed words"] = "pblendw:混合打包字",
["Blend packed dwords"] = "vpblendd:混合打包双字",
["Variable blend packed bytes"] = "vpblendvb:可变混合打包字节",
["Variable blend packed double precision floating%-point values"] = "vblendvpd:可变混合打包双精度",
["Variable Blend Packed Single Precision Floating%-Point Values"] = "vblendvps:可变混合打包单精度",
["Permute floating%-point values"] = "vpermil:置换浮点数",
["Permute single%-precision floating%-point values"] = "vpermps:置换单精度",
["permute single%-precision floating%-point values"] = "vpermps:置换单精度",
["Permute single%-precision floating%-point elements"] = "vpermps:置换单精度元素",
["Permute single%-prevision floating%-point values"] = "vpermps:置换单精度",
["Permute double%-precision floating%-point values"] = "vpermpd:置换双精度",
["permute double%-precision floating%-point values"] = "vpermpd:置换双精度",
["Permute double%-precision floating%-point elements"] = "vpermpd:置换双精度元素",
["Permute double%-prevision floating%-point values"] = "vpermpd:置换双精度",
["Permute integer values"] = "vpermd:置换整数",
["Full doublewords element permutation"] = "vpermd:双字元素置换",
["Qwords element permutation"] = "vpermq:四字元素置换",
["Broadcast integer data"] = "vpbroadcast:广播整数",
["Broadcast floating%-point%-data"] = "vbroadcast:广播浮点数",
-- ========== SSE/AVX 舍入 ==========
["Round packed double precision floating%-point values"] = "roundpd:舍入打包双精度",
["Round packed single precision floating%-point values"] = "roundps:舍入打包单精度",
["Round scalar single precision floating%-point values"] = "roundss:舍入标量单精度",
-- ========== FMA 融合乘加 ==========
["Fused multiply%-add of packed single%-precision floating%-point%-values"] = "vfmadd:融合乘加打包单精度",
["Fused multiple%-add of packed single precision floating%-point%-values"] = "vfmadd:融合乘加打包单精度",
["Fused multiple%-add of packed double precision floating%-point%-values"] = "vfmadd:融合乘加打包双精度",
["Fused multiple%-add of scalar double precision floating%-point%-values"] = "vfmadd:融合乘加标量双精度",
["Fused multiple%-add of scalar single precision floating%-point%-values"] = "vfmadd:融合乘加标量单精度",
["Fused multiple%-subtract of packed single precision floating%-point%-values"] = "vfmsub:融合乘减打包单精度",
["Fused multiple%-subtract of packed double precision floating%-point%-values"] = "vfmsub:融合乘减打包双精度",
["Fused multiple%-subtract of scalar double precision floating%-point%-values"] = "vfmsub:融合乘减标量双精度",
["Fused multiple%-subtract of scalar single precision floating%-point%-values"] = "vfmsub:融合乘减标量单精度",
["Fused negative multiply%-add of packed single%-precision floating%-point%-values"] = "vfnmadd:融合负乘加打包单精度",
["Fused negative multiply%-add of packed double precision floating%-point%-values"] = "vfnmadd:融合负乘加打包双精度",
["Fused negative multiply%-add of scalar double precision floating%-point%-values"] = "vfnmadd:融合负乘加标量双精度",
["Fused negative multiply%-add of scalar single precision floating%-point%-values"] = "vfnmadd:融合负乘加标量单精度",
["Fused negative multiply%-subtract of packed double precision floating%-point%-values"] = "vfnmsub:融合负乘减打包双精度",
["Fused negative multiply%-subtract of packed single precision floating%-point%-values"] = "vfnmsub:融合负乘减打包单精度",
["Fused negative multiply%-subtract of scalar double precision floating%-point%-values"] = "vfnmsub:融合负乘减标量双精度",
["Fused begative multiply%-subtract of scalar single precision floating%-point%-values"] = "vfnmsub:融合负乘减标量单精度",
["Fused multiply%-alternating add/subtract of packed double precision floating%-point%-values"] = "vfmaddsub:融合乘加减交替双精度",
["Fused multiply%-alternating add/subtract of packed single precision floating%-point%-values"] = "vfmaddsub:融合乘加减交替单精度",
["Fused multiply%-alternating subtract/add of packed double precision floating%-point%-values"] = "vfmsubadd:融合乘减加交替双精度",
["Fused multiply%-alternating subtract/add of packed single precision floating%-point%-values"] = "vfmsubadd:融合乘减加交替单精度",
["Fused multiple%-alnterating add/subtract of packed double precision floating%-point%-values"] = "vfmaddsub:融合乘加减交替双精度",
["Fused multiple%-alnterating add/subtract of precision floating%-point%-values"] = "vfmaddsub:融合乘加减交替单精度",
["Fused multiple%-alnterating subtract/add of packed double precision floating%-point%-values"] = "vfmsubadd:融合乘减加交替双精度",
["Fused multiple%-alnterating subtract/add of precision floating%-point%-values"] = "vfmsubadd:融合乘减加交替单精度",
-- ========== AVX Gather ==========
["Gather Packed SP FP values Using Signed Dword/Qword Indices"] = "vgatherdps:聚集加载单精度",
["Gather Packed DP FP Values Using Signed Dword/Qword Indices"] = "vgatherdpd:聚集加载双精度",
-- ========== AVX 其他 ==========
["Zero upper bits of YMM registers"] = "vzeroupper:清零YMM高位",
["Zero all YMM registers"] = "vzeroall:清零所有YMM",
["Variable Bit Shift Left Logical"] = "vpsllv/shlx:可变位逻辑左移",
["Variable Bit Shift Right Logical"] = "vpsrlv/shrx:可变位逻辑右移",
["Variable bit shift right arithmetic"] = "vpsrav/sarx:可变位算术右移",
["Conditional SIMD Integer Packed Loads and Stores"] = "vpmaskmov:条件打包整数加载/存储",
["Conditional SIMD packed loads and stores"] = "vmaskmov:条件打包浮点加载/存储",
["Load double quadword non%-temporal aligned hint"] = "movntdqa:非临时对齐加载双四字",
-- ========== 内存屏障与非临时 ==========
["Load Fence"] = "lfence:读取屏障",
["store fence"] = "sfence:写入屏障",
["memory fence"] = "mfence:内存屏障",
["prefetch"] = "prefetch:预取数据",
["Prefetch Data into Caches in Anticipation of a Write"] = "prefetchw:预取数据(写意图)",
["Prefetch Vector Data Into Caches with Intent to Write and T1 Hint"] = "prefetchwt1:预取向量数据",
["store doubleword using non%-temporal hint"] = "movnti:双字非临时存储",
["move aligned four packed single%-fp non temporal"] = "movntps:打包单精度非临时存储",
["move double quadword using non%-temporal hint"] = "movntdq:双四字非临时存储",
["move packed double%-precision floating%-point using non%-temporal hint"] = "movntpd:打包双精度非临时存储",
["load unaligned integer 128 bits"] = "lddqu:加载未对齐128位整数",
["store selected bytes of double quadword"] = "maskmovdqu:按掩码存储双四字",
["byte mask write"] = "maskmovq:按字节掩码写入",
-- ========== 原子操作 ==========
["compare and exchange"] = "cmpxchg:比较并交换",
["compare and exchange 8 bytes"] = "cmpxchg8b:比较并交换8字节",
["exchange and add"] = "xadd:交换并加法",
-- ========== 系统指令 ==========
["fast transistion to system call entry point"] = "sysenter:快速进入系统调用",
["fast transistion from system call entry point"] = "sysexit:快速从系统调用返回",
["fast system call"] = "syscall:快速系统调用",
["return from fast system call"] = "sysret:从快速系统调用返回",
["resume from system management mode"] = "rsm:从系统管理模式返回",
["cpu identification"] = "cpuid:获取CPU信息",
["read time%-stamp counter"] = "rdtsc:读取时间戳计数器",
["Read time%-stamp counter and processor ID"] = "rdtscp:读取时间戳和处理器ID",
["read performance%-monitoring counters"] = "rdpmc:读取性能监控计数器",
["read from model specific register"] = "rdmsr:读取MSR寄存器",
["write to model specific register"] = "wrmsr:写入MSR寄存器",
-- ========== 描述符表 ==========
["load global descriptor table register"] = "lgdt:加载GDTR",
["store global descriptor table register"] = "sgdt:存储GDTR",
["load interupt descriptor table register"] = "lidt:加载IDTR",
["store interrupt descriptor table register"] = "sidt:存储IDTR",
["load local descriptor table register"] = "lldt:加载LDTR",
["store local descriptor table register"] = "sldt:存储LDTR",
["load task register"] = "ltr:加载任务寄存器",
["store task register"] = "str:存储任务寄存器",
["load machine status word"] = "lmsw:加载机器状态字",
["store machine status word"] = "smsw:存储机器状态字",
["clear task%-switched flag in cr0"] = "clts:清除CR0任务切换标志",
["load access rights byte"] = "lar:加载段访问权限",
["load segment limit"] = "lsl:加载段限制",
["verify a segment for reading"] = "verr:验证段可读",
["verify a segment for writing"] = "verw:验证段可写",
["adjust rpl field of segment selector"] = "arpl:调整段选择器RPL",
["load far pointer"] = "lfs/lgs/lss:加载远指针",
-- ========== 缓存/TLB ==========
["invalidate internal caches"] = "invd:使缓存失效",
["write back and invalidate cache"] = "wbinvd:写回并使缓存失效",
["invalidate tlb entry"] = "invlpg:使TLB条目无效",
["Invalidate process%-context%-identifier"] = "invpcid:使进程上下文标识符无效",
-- ========== 控制/调试寄存器 ==========
["move from control register"] = "mov:从控制寄存器读取",
["move to control register"] = "mov:写入控制寄存器",
["move from debug register"] = "mov:从调试寄存器读取",
["move to debug register"] = "mov:写入调试寄存器",
-- ========== 扩展状态 ==========
["store streaming simd extension control/status"] = "stmxcsr:存储MXCSR",
["load streaming simd extension control/status"] = "ldmxcsr:加载MXCSR",
["save processor extended state"] = "xsave:保存扩展状态",
["save processor extended status optimized"] = "xsaveopt:优化保存扩展状态",
["save processor extended state with compaction"] = "xsavec:压缩保存扩展状态",
["save processor extended state supervisor"] = "xsaves:保存扩展状态(管理模式)",
["restore processor extended state"] = "xrstor:恢复扩展状态",
["restore processor extended status supervisor"] = "xrstors:恢复扩展状态(管理模式)",
["save fp and mmx state and streaming simd extension state"] = "fxsave:保存FPU/MMX/SSE状态",
["store fp and mmx state and streaming simd extension state"] = "fxsave:保存FPU/MMX/SSE状态",
["restore fp and mmx state and streaming simd extension state"] = "fxrstor:恢复FPU/MMX/SSE状态",
["Get value of extended control register"] = "xgetbv:获取扩展控制寄存器值",
["Set value of extended control register"] = "xsetbv:设置扩展控制寄存器值",
-- ========== VMX 虚拟化 ==========
["call to vm monitor by causing vm exit"] = "vmcall:调用虚拟机监控器",
["launch virtual machine managed by current vmcs"] = "vmlaunch:启动虚拟机",
["resume virtual machine managed by current vmcs"] = "vmresume:恢复虚拟机",
["leaves vmx operation"] = "vmxoff:退出VMX操作",
["enter vmx root operation"] = "vmxon:进入VMX根操作",
["copy vmcs data to vmcs region in memory"] = "vmclear:清除VMCS数据",
["reads a specified vmcs field %(32 bits%)"] = "vmread:读取VMCS字段",
["writes a specified vmcs field %(32 bits%)"] = "vmwrite:写入VMCS字段",
["loads the current vmcs pointer from memory"] = "vmptrld:加载VMCS指针",
["stores the current vmcs pointer into memory"] = "vmptrst:存储VMCS指针",
["set up monitor address"] = "monitor:设置监控地址",
["Monitor wait"] = "mwait:监控等待",
["Clear AC flag in EFLAGS register"] = "clac:清除AC标志",
["Swap GS base register"] = "swapgs:交换GS基址",
-- ========== TSX 事务内存 ==========
["Transactional Begin"] = "xbegin:事务开始",
["Transactional end"] = "xend:事务结束",
["transactional abort"] = "xabort:事务中止",
["Test if in transactional execution"] = "xtest:测试是否在事务中",
-- ========== AES 加密 ==========
["AES round key generation assist"] = "aeskeygenassist:AES轮密钥生成",
["Perform one round of an AES encryption flow"] = "aesenc:AES加密一轮",
["Perform last round of an AES encryption flow"] = "aesenclast:AES加密最后一轮",
["Perform one round of an AES decryption flow"] = "aesdec:AES解密一轮",
["Perform last round of an AES decryption flow"] = "aesdeclast:AES解密最后一轮",
["Perform the AES InvMixColumn transformation"] = "aesimc:AES逆列混合",
["Carry%-less multiplication quadword"] = "pclmulqdq:无进位四字乘法",
["Safermode multipurpose function"] = "getsec:安全模式多功能指令",
-- ========== ADX/CRC32/随机数 ==========
["ADX: Unsigned Integer Addition of Two Operands with Carry Flag"] = "adcx:带进位无符号加法",
["ADX: Unsigned Integer Addition of Two Operands with Overflow Flag"] = "adox:带溢出无符号加法",
["Accumulate CRC32 value"] = "crc32:累积CRC32值",
["read random numer"] = "rdrand:读取硬件随机数",
["read random SEED"] = "rdseed:读取随机种子",
-- ========== FS/GS 基址 ==========
["read fs base address"] = "rdfsbase:读取FS基址",
["read gs base address"] = "rdgsbase:读取GS基址",
["write fs base address"] = "wrfsbase:写入FS基址",
["write gs base address"] = "wrgsbase:写入GS基址",
-- ========== BMI2 无标志位操作 ==========
["Unsigned multiple without affecting flags"] = "mulx:无符号乘法(不影响标志)",
["Rotate right logical without affecting flags"] = "rorx:循环右移(不影响标志)",
["Shift logically left without affecting flags"] = "shlx:逻辑左移(不影响标志)",
["Shift logically right without affecting flags"] = "shrx:逻辑右移(不影响标志)",
["Shift arithmetically right without affecting flags"] = "sarx:算术右移(不影响标志)",
-- ========== I/O 端口 ==========
["input from port"] = "in:从端口输入",
["output to port"] = "out:向端口输出",
["output toport"] = "out:向端口输出",
["output string to port"] = "outs:串输出到端口",
["input from port to string"] = "ins:从端口输入到串",
-- ========== 杂项 ==========
["table look%-up translation"] = "xlat:查表转换",
["undefined instruction%(yes, this one really excists%.%.%)"] = "ud2:未定义指令",
["undefined by the intel specification"] = "db:Intel未定义",
["not specified by the intel documentation"] = "db:Intel未定义",
["not defined by the intel documentation"] = "db:Intel未定义",
["multibyte nop"] = "nop:多字节空指令",
["ascii adjust al after addition"] = "aaa:加法后ASCII调整",
["ascii adjust al after subtraction"] = "aas:减法后ASCII调整",
["ascii adjust ax after multiply"] = "aam:乘法后ASCII调整",
["ascii adjust ax before division"] = "aad:除法前ASCII调整",
["decimal adjust al after addition"] = "daa:加法后十进制调整",
["decimal adjust al after subtraction"] = "das:减法后十进制调整",
["Filler"] = "db:填充字节",
}
-- =============================================================================
-- 2. 动态匹配模式
-- =============================================================================
local GenericPatterns = {
-- 加法指令
{"^add (%x+) to eax$", "add:加法 (0x%1 到 EAX)"},
{"^add (%x+) to rax$", "add:加法 (0x%1 到 RAX)"},
{"^add (%x+) to ax$", "add:加法 (0x%1 到 AX)"},
{"^Add (%x+) to AL$", "add:加法 (0x%1 到 AL)"},
{"^add (%x+) to eax %(sign extended%)$", "add:加法 (0x%1 到 EAX,符号扩展)"},
{"^add (%x+) to rax %(sign extended%)$", "add:加法 (0x%1 到 RAX,符号扩展)"},
{"^add (%w+) to (%w+)$", "add:加法 (%1 到 %2)"},
-- 返回指令
{"^near return to calling procedure and pop (%d+) bytes from stack$", "ret:近返回并弹出 %1 字节"},
{"^near return to calling procedure and pop$", "ret:近返回并弹出字节"},
{"^far return to calling procedure and pop (%d+) bytes from stack$", "retf:远返回并弹出 %1 字节"},
-- 循环移位 (8/9/16/17/32/33/64/65 bits)
{"^rotate eight bits left$", "rcl:带进位循环左移 8 位"},
{"^rotate eight bits left cl times$", "rcl:带进位循环左移 CL 位 (8位)"},
{"^rotate eight bits left once$", "rcl:带进位循环左移 1 位 (8位)"},
{"^rotate eight bits right$", "rcr:带进位循环右移 8 位"},
{"^rotate eight bits right cl times$", "rcr:带进位循环右移 CL 位 (8位)"},
{"^rotate eight bits right once$", "rcr:带进位循环右移 1 位 (8位)"},
{"^rotate nine bits left$", "rcl:带进位循环左移 9 位"},
{"^rotate nine bits left cl times$", "rcl:带进位循环左移 CL 位 (9位)"},
{"^rotate nine bits left once$", "rcl:带进位循环左移 1 位 (9位)"},
{"^rotate nine bits right$", "rcr:带进位循环右移 9 位"},
{"^rotate nine bits right cl times$", "rcr:带进位循环右移 CL 位 (9位)"},
{"^rotate nine bits right once$", "rcr:带进位循环右移 1 位 (9位)"},
{"^rotate ([%w%-]+) bits left (%d+) times$", "rol:循环左移 %2 位"},
{"^rotate ([%w%-]+) bits right (%d+) times$", "ror:循环右移 %2 位"},
{"^rotate ([%w%-]+) bits left cl times$", "rol:循环左移 CL 位"},
{"^rotate ([%w%-]+) bits right cl times$", "ror:循环右移 CL 位"},
{"^rotate ([%w%-]+) bits left once$", "rol:循环左移 1 位"},
{"^rotate ([%w%-]+) bits right once$", "ror:循环右移 1 位"},
-- 移位指令
{"^multiply by 2,? (%d+) times$", "shl:逻辑左移 %1 位 (×2^%1)"},
{"^multiply by 2,? once$", "shl:逻辑左移 1 位 (×2)"},
{"^multiply by 2,? cl times$", "shl:逻辑左移 CL 位"},
{"^multiply by 2$", "shl:逻辑左移 (×2)"},
{"^signed multiply by 2,? (%d+) times$", "sal:算术左移 %1 位 (×2^%1)"},
{"^signed multiply by 2,? once$", "sal:算术左移 1 位 (×2)"},
{"^signed multiply by 2,? cl times$", "sal:算术左移 CL 位"},
{"^signed multiply by 2$", "sal:算术左移 (×2)"},
{"^unsigned divide by 2,? (%d+) times$", "shr:逻辑右移 %1 位 (÷2^%1)"},
{"^unsigned divide by 2,? once$", "shr:逻辑右移 1 位 (÷2)"},
{"^unsigned divide by 2,? cl times$", "shr:逻辑右移 CL 位"},
{"^unsigned divide by 2$", "shr:逻辑右移 (÷2)"},
{"^signed divide by 2,? (%d+) times$", "sar:算术右移 %1 位 (÷2^%1)"},
{"^signed divide by 2,? once$", "sar:算术右移 1 位 (÷2)"},
{"^signed divide by 2,? cl times$", "sar:算术右移 CL 位"},
{"^signed divide by 2$", "sar:算术右移 (÷2)"},
-- SIMD 逻辑
{"^bit%-wise logical and not of packed double%-precision fp values$", "andnpd:双精度逻辑与非"},
{"^bit%-wise logical and not for single%-fp$", "andnps:单精度逻辑与非"},
{"^bit%-wise logical and for single fp$", "andps:单精度逻辑与"},
{"^bit%-wise logical or of double%-fp$", "orpd:双精度逻辑或"},
{"^bit%-wise logical or for single%-fp$", "orps:单精度逻辑或"},
{"^bit%-wise logical xor for single%-fp data$", "xorps:单精度逻辑异或"},
{"^bit%-wise logical xor for double%-fp data$", "xorpd:双精度逻辑异或"},
}
-- =============================================================================
-- 3. 运行时状态
-- =============================================================================
local mv = getMemoryViewForm()
local disView = mv and mv.DisassemblerView
local sourcePanel = nil
local overlayPanel = nil
local overlayLabel = nil
local lastSourceText = ""
local delayTimer = nil
local originalOnSelectionChange = nil
-- =============================================================================
-- 4. 核心函数
-- =============================================================================
-- 查找描述面板
local function findDescriptionPanel()
if not disView or not disView.ControlCount then return nil end
for i = 0, disView.ControlCount - 1 do
local ctrl = disView.getControl(i)
if ctrl.ClassName == "TPanel" then
local cap = ctrl.Caption or ""
if cap ~= "" and string_match(cap, "[a-zA-Z]") then
return ctrl
end
end
end
return nil
end
-- 翻译文本
local function translateText(text)
if not text or text == "" then return nil end
local lowerText = string_lower(text)
-- 精确匹配
for eng, chn in pairs(OpcodesTab) do
if string_find(text, "^" .. eng .. "$") or string_find(lowerText, "^" .. string_lower(eng) .. "$") then
return chn
end
end
-- 模式匹配
for _, pattern in ipairs(GenericPatterns) do
local captures = {string_match(lowerText, pattern[1])}
if #captures > 0 then
local result = pattern[2]
for i, cap in ipairs(captures) do
result = string_gsub(result, "%%" .. i, cap)
end
return result
end
end
return nil
end
-- 居中标签
local function centerOverlay()
if not overlayLabel or not overlayPanel then return end
overlayLabel.Left = math_floor((overlayPanel.Width - overlayLabel.Width) / 2)
overlayLabel.Top = math_floor((overlayPanel.Height - overlayLabel.Height) / 2)
end
-- 创建覆盖层
local function createOverlay()
if overlayLabel or not sourcePanel then return overlayLabel ~= nil end
overlayPanel = createPanel(sourcePanel)
overlayPanel.Name = "TranslateOverlayPanel"
overlayPanel.Align = alClient
overlayPanel.BevelOuter = bvNone
overlayPanel.Color = sourcePanel.Color
overlayPanel.Caption = ""
overlayPanel.BringToFront()
overlayPanel.OnResize = centerOverlay
overlayLabel = createLabel(overlayPanel)
overlayLabel.Name = "TranslateOverlay"
overlayLabel.Font.Color = 0xFF0000
overlayLabel.Font.Size = 10
overlayLabel.Caption = ""
overlayLabel.Visible = true
overlayLabel.AutoSize = true
overlayLabel.Transparent = true
return true
end
-- 执行翻译
local function doTranslate()
if not sourcePanel then
sourcePanel = findDescriptionPanel()
if sourcePanel then createOverlay() else return end
end
if not overlayLabel then
createOverlay()
return
end
local currentText = sourcePanel.Caption
if currentText ~= lastSourceText then
lastSourceText = currentText
local translated = translateText(currentText)
overlayLabel.Caption = translated or currentText or ""
centerOverlay()
end
overlayPanel.BringToFront()
end
-- 延迟翻译
local function delayedTranslate()
if delayTimer then
delayTimer.destroy()
delayTimer = nil
end
delayTimer = createTimer(nil)
delayTimer.Interval = 20
delayTimer.OnTimer = function(timer)
timer.Enabled = false
timer.destroy()
delayTimer = nil
doTranslate()
end
end
-- 清理资源
local function cleanup()
if delayTimer then delayTimer.destroy(); delayTimer = nil end
if disView and originalOnSelectionChange then
disView.OnSelectionChange = originalOnSelectionChange
end
if overlayLabel then overlayLabel.destroy(); overlayLabel = nil end
if overlayPanel then overlayPanel.destroy(); overlayPanel = nil end
sourcePanel = nil
lastSourceText = ""
end
-- =============================================================================
-- 5. 初始化
-- =============================================================================
cleanup()
if disView then
originalOnSelectionChange = disView.OnSelectionChange
disView.OnSelectionChange = function(sender)
if originalOnSelectionChange then pcall(originalOnSelectionChange, sender) end
delayedTranslate()
end
sourcePanel = findDescriptionPanel()
if sourcePanel then
createOverlay()
doTranslate()
end
end