diff options
author | Max Bernstein <emacs@fb.com> | 2021-02-25 23:22:01 -0800 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:30 -0400 |
commit | 3a365afaf555e3c1b6758df4431b8f659ff310a2 (patch) | |
tree | edc5a125ee04b0bf8f0edcc12ceedc6ed12ae915 /ujit_asm.c | |
parent | 799d248e314d98b28837b921c9e0fc97ae93b574 (diff) |
Support memory operands to push
Diffstat (limited to 'ujit_asm.c')
-rw-r--r-- | ujit_asm.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ujit_asm.c b/ujit_asm.c index 3355acae90..8eb5da7593 100644 --- a/ujit_asm.c +++ b/ujit_asm.c @@ -1452,17 +1452,22 @@ void popfq(codeblock_t* cb) cb_write_bytes(cb, 2, 0x48, 0x9D); } -/// push - Push a register on the stack -void push(codeblock_t* cb, x86opnd_t reg) +/// push - Push an operand on the stack +void push(codeblock_t* cb, x86opnd_t opnd) { - assert (reg.num_bits == 64); + assert (opnd.num_bits == 64); - //cb.writeASM("push", reg); + //cb.writeASM("push", opnd); - if (rex_needed(reg)) - cb_write_rex(cb, false, 0, 0, reg.as.reg.reg_no); - - cb_write_opcode(cb, 0x50, reg); + if (opnd.type == OPND_REG) { + if (rex_needed(opnd)) + cb_write_rex(cb, false, 0, 0, opnd.as.reg.reg_no); + cb_write_opcode(cb, 0x50, opnd); + } else if (opnd.type == OPND_MEM) { + cb_write_rm(cb, false, false, NO_OPND, opnd, 6, 1, 0xFF); + } else { + assert(false && "unexpected operand type"); + } } /// pushfq - Push the flags register (64-bit) |