]> git.feebdaed.xyz Git - 0xmirror/radare2.git/commitdiff
Fix #25037 - Support to assemble the 'enter' instruction for x86 ##arch
authorpancake <trufae@gmail.com>
Mon, 15 Dec 2025 14:55:30 +0000 (15:55 +0100)
committerGitHub <noreply@github.com>
Mon, 15 Dec 2025 14:55:30 +0000 (15:55 +0100)
libr/arch/p/x86_nz/nzasm.c

index 7062de0ea68dd03039aab22e7fad961e0f073a6c..3f05482ac679e81fcf62edbaa9ef51bec70383b8 100644 (file)
@@ -2282,6 +2282,24 @@ static int opint(RArchSession *a, ut8 *data, const Opcode *op) {
        return l;
 }
 
+// enter imm16, imm8 - Create stack frame
+static int openter(RArchSession *a, ut8 *data, const Opcode *op) {
+       if (op->operands_count != 2) {
+               R_LOG_ERROR ("Missing operands for the enter instruction");
+               return -1;
+       }
+       if ((op->operands[0].type & OT_CONSTANT) && (op->operands[1].type & OT_CONSTANT)) {
+               ut16 framesize = op->operands[0].immediate;
+               ut8 nesting = op->operands[1].immediate;
+               data[0] = 0xc8;
+               data[1] = framesize & 0xff;
+               data[2] = (framesize >> 8) & 0xff;
+               data[3] = nesting;
+               return 4;
+       }
+       return -1;
+}
+
 static int opjc(RArchSession *a, ut8 *data, const Opcode *op) {
        is_valid_registers (op);
        int l = 0;
@@ -5030,6 +5048,7 @@ static const LookupTable oplookup[] = {
        { "emms", 0, NULL, 0x0f77, 2},
        { "endbr32", 0, endbr32, 0},
        { "endbr64", 0, endbr64, 0},
+       { "enter", 0, &openter, 0},
        { "f2xm1", 0, NULL, 0xd9f0, 2},
        { "fabs", 0, NULL, 0xd9e1, 2},
        { "fadd", 0, &opfadd, 0},