mirror of
https://github.com/ruby/ruby.git
synced 2025-09-22 03:53:58 +02:00
Add sign-extended mode for test() instruction
This commit is contained in:
parent
8ae354e9be
commit
868a6809e7
2 changed files with 24 additions and 11 deletions
14
ujit_asm.c
14
ujit_asm.c
|
@ -1516,7 +1516,9 @@ void test(codeblock_t* cb, x86opnd_t rm_opnd, x86opnd_t test_opnd)
|
|||
if (test_opnd.type == OPND_IMM)
|
||||
{
|
||||
x86opnd_t imm_opnd = test_opnd;
|
||||
assert (imm_opnd.as.imm >= 0);
|
||||
|
||||
if (imm_opnd.as.imm >= 0)
|
||||
{
|
||||
assert (unsig_imm_size(imm_opnd.as.unsig_imm) <= 32);
|
||||
assert (unsig_imm_size(imm_opnd.as.unsig_imm) <= rm_opnd.num_bits);
|
||||
|
||||
|
@ -1535,6 +1537,16 @@ void test(codeblock_t* cb, x86opnd_t rm_opnd, x86opnd_t test_opnd)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This mode only applies to 64-bit R/M operands with 32-bit signed immediates
|
||||
assert (imm_opnd.as.imm < 0);
|
||||
assert (sig_imm_size(imm_opnd.as.imm) <= 32);
|
||||
assert (rm_opnd.num_bits == 64);
|
||||
cb_write_rm(cb, false, true, NO_OPND, rm_opnd, 0x00, 1, 0xF7);
|
||||
cb_write_int(cb, imm_opnd.as.imm, 32);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// For now, 32-bit operands only
|
||||
assert (test_opnd.num_bits == rm_opnd.num_bits);
|
||||
|
|
|
@ -315,6 +315,7 @@ void run_tests()
|
|||
cb_set_pos(cb, 0); test(cb, mem_opnd(8, RSI, 16), imm_opnd(1)); check_bytes(cb, "F6461001");
|
||||
cb_set_pos(cb, 0); test(cb, mem_opnd(8, RSI, -16), imm_opnd(1)); check_bytes(cb, "F646F001");
|
||||
cb_set_pos(cb, 0); test(cb, mem_opnd(32, RSI, 64), EAX); check_bytes(cb, "854640");
|
||||
cb_set_pos(cb, 0); test(cb, mem_opnd(64, RSI, 64), imm_opnd(~0x08)); check_bytes(cb, "48F74640F7FFFFFF");
|
||||
|
||||
// xor
|
||||
cb_set_pos(cb, 0); xor(cb, EAX, EAX); check_bytes(cb, "31C0");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue