diff options
Diffstat (limited to 'instructions.h')
| -rw-r--r-- | instructions.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/instructions.h b/instructions.h index 9727137..1623ff0 100644 --- a/instructions.h +++ b/instructions.h @@ -47,6 +47,20 @@ #define MOVABS(reg, imm) 0x48, MOVD(reg, imm) #define MOVQ(reg, imm) 0x48, 89 c8 +#define MODRM(mod, reg, rm) (((mod & 3) << 6) | ((reg & 7) << 3) | (rm & 3)) +// MOD REG RM (r/m = register/memory) +// 1 1 | 1 0 1 | 1 0 1 +// if mod == 0b11, then treat r/m as register, +// (examples in OP SRC DST ordering (same as the reg-rm order) +// gas/at&t ASM => op reg-idx reg-idx => MOD | REG | RM +// --------------------+----------------------+--------------------- +// ie "xor %rcx, %rcx" => XOR 1 1 => 1 1 | 0 0 1 | 0 0 1 +// ie "xor %rsi, %rbp" => XOR 6 5 => 1 1 | 1 0 1 | 1 1 0 +// +// Other combinations of MOD means RM specifies an addressing mode. +// For 64bit systems: +// + #define ADD #define CALL #define CMP @@ -64,10 +78,10 @@ #define LEA #define POP #define PUSH -#define RET +#define RET 0xc3 #define RETN #define SUB -#define XOR +#define XOR /*TODO*/ #define SYSCALL 0x0f, 0x05 |
