diff --git a/libr/asm/p/asm_x86_nz.c b/libr/asm/p/asm_x86_nz.c index 25130e58eae0a..92b4fab97acdf 100644 --- a/libr/asm/p/asm_x86_nz.c +++ b/libr/asm/p/asm_x86_nz.c @@ -2284,6 +2284,28 @@ static int opmov(RAsm *a, ut8 *data, const Opcode *op) { return l; } +// Only for MOV r64, imm64 +static int opmovabs(RAsm *a, ut8 *data, const Opcode *op) { + if (!(a->bits == 64 && (op->operands[0].type & OT_GPREG) && !(op->operands[0].type & OT_MEMORY) && + (op->operands[0].type & OT_QWORD) && (op->operands[1].type & OT_CONSTANT))) { + return -1; + } + int l = 0; + int byte_shift; + ut64 immediate; + if (op->operands[0].extended) { + data[l++] = 0x49; + } else { + data[l++] = 0x48; + } + data[l++] = 0xb8 | op->operands[0].reg; + immediate = op->operands[1].immediate * op->operands[1].sign; + for (byte_shift = 0; byte_shift < 8; byte_shift++) { + data[l++] = immediate >> (byte_shift * 8); + } + return l; +} + static int opmul(RAsm *a, ut8 *data, const Opcode *op) { is_valid_registers (op); int l = 0; @@ -4339,6 +4361,7 @@ LookupTable oplookup[] = { {"movsw", 0, NULL, 0x66a5, 2}, {"movzx", 0, &opmovx, 0}, {"movsx", 0, &opmovx, 0}, + {"movabs", 0, &opmovabs, 0}, {"mul", 0, &opmul, 0}, {"mwait", 0, NULL, 0x0f01c9, 3}, {"neg", 0, &opneg, 0}, diff --git a/test/new/db/asm/x86_64 b/test/new/db/asm/x86_64 index 9395ade4ff0c8..bdbf7c7e0b41c 100644 --- a/test/new/db/asm/x86_64 +++ b/test/new/db/asm/x86_64 @@ -729,6 +729,8 @@ aB "mov qword[r12], rsp" 49892424 aB "mov qword[r8 + 0x20], rax" 49894020 aB "mov r12, qword[r12]" 4d8b2424 a "mov eax,r12d" 4489e0 +ad "movabs rax, 0xdeadbeef" 48b8efbeadde00000000 +ad "movabs r12, 1" 49bc0100000000000000 a "inc al" fec0 a "inc BYTE PTR [r12]" 41fe0424 a "inc BYTE PTR [rbx+0x18]" fe4318