How to determine if ModR/M is needed through Opcodes?

Intel’s vol.2 manual has details on the encoding of operands for each form of each instruction. E.g. taking just the 8-bit operand size versions of the well-known add instruction, which has 2 reg,rm forms ; a rm,immediate form ; and a no-ModRM 2-byte short form for add al, imm8 Opcode Instruction | Op/En | 64-bit … Read more

execute binary machine code from C

The code must be in a page with execute permission. By default, stack and read-write static data (like non-const globals) are in pages mapped without exec permission, for security reasons. The simplest way is to compile with gcc -z execstack, which links your program such that stack and global variables (static storage) get mapped in … Read more

Avoiding getfield opcode

My guess is that the point is to copy the values into local variables once, to avoid having to fetch the field value repeatedly from the heap for each iteration of the loop in the next few lines. Of course, that begs the question as to why the same comment hasn’t been applied on the … Read more