mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Support memory operands to pop
This commit is contained in:
parent
831ac473fa
commit
f63cdae3a3
2 changed files with 17 additions and 7 deletions
19
ujit_asm.c
19
ujit_asm.c
|
@ -1431,16 +1431,21 @@ void or(codeblock_t* cb, x86opnd_t opnd0, x86opnd_t opnd1)
|
|||
}
|
||||
|
||||
/// pop - Pop a register off the stack
|
||||
void pop(codeblock_t* cb, x86opnd_t reg)
|
||||
void pop(codeblock_t* cb, x86opnd_t opnd)
|
||||
{
|
||||
assert (reg.num_bits == 64);
|
||||
assert (opnd.num_bits == 64);
|
||||
|
||||
//cb.writeASM("pop", reg);
|
||||
//cb.writeASM("pop", opnd);
|
||||
|
||||
if (rex_needed(reg))
|
||||
cb_write_rex(cb, false, 0, 0, reg.as.reg.reg_no);
|
||||
|
||||
cb_write_opcode(cb, 0x58, 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, 0x58, opnd);
|
||||
} else if (opnd.type == OPND_MEM) {
|
||||
cb_write_rm(cb, false, false, NO_OPND, opnd, 0, 1, 0x8F);
|
||||
} else {
|
||||
assert(false && "unexpected operand type");
|
||||
}
|
||||
}
|
||||
|
||||
/// popfq - Pop the flags register (64-bit)
|
||||
|
|
|
@ -279,6 +279,11 @@ void run_tests()
|
|||
cb_set_pos(cb, 0); pop(cb, RSP); check_bytes(cb, "5C");
|
||||
cb_set_pos(cb, 0); pop(cb, RBP); check_bytes(cb, "5D");
|
||||
cb_set_pos(cb, 0); pop(cb, R12); check_bytes(cb, "415C");
|
||||
cb_set_pos(cb, 0); pop(cb, mem_opnd(64, RAX, 0)); check_bytes(cb, "8F00");
|
||||
cb_set_pos(cb, 0); pop(cb, mem_opnd(64, R8, 0)); check_bytes(cb, "418F00");
|
||||
cb_set_pos(cb, 0); pop(cb, mem_opnd(64, R8, 3)); check_bytes(cb, "418F4003");
|
||||
cb_set_pos(cb, 0); pop(cb, mem_opnd_sib(64, RAX, RCX, 8, 3)); check_bytes(cb, "8F44C803");
|
||||
cb_set_pos(cb, 0); pop(cb, mem_opnd_sib(64, R8, RCX, 8, 3)); check_bytes(cb, "418F44C803");
|
||||
|
||||
// push
|
||||
cb_set_pos(cb, 0); push(cb, RAX); check_bytes(cb, "50");
|
||||
|
|
Loading…
Reference in a new issue