From: Peter Johnson Date: Sat, 10 Jun 2006 18:35:36 +0000 (-0000) Subject: x86_bc_insn_tobytes(): Fix the case where we get here with imm8 post-op X-Git-Tag: v0.6.0~172^2~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e96f6a5b9c9a929dc614d0f4b20156f126bc4ed;p=yasm x86_bc_insn_tobytes(): Fix the case where we get here with imm8 post-op still enabled; we need to fix up the immlen to 8 (as it's maintained with the wordsize version up to this point). svn path=/branches/new-optimizer/; revision=1565 --- diff --git a/modules/arch/x86/x86bc.c b/modules/arch/x86/x86bc.c index 5ee794c0..b5e5cd83 100644 --- a/modules/arch/x86/x86bc.c +++ b/modules/arch/x86/x86bc.c @@ -570,6 +570,7 @@ x86_bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, * permanent. */ imm->val.size = 8; + imm->sign = 1; immlen = 8; } else { /* We can't. Copy over the word-sized opcode. */ @@ -845,7 +846,16 @@ x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, /* Immediate (if required) */ if (imm) { - unsigned int imm_len = imm->val.size/8; + unsigned int imm_len; + if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { + /* If we got here with this postop still set, we need to force + * imm size to 8 here. + */ + imm->val.size = 8; + imm->sign = 1; + imm_len = 1; + } else + imm_len = imm->val.size/8; if (output_value(&imm->val, *bufp, imm_len, (unsigned long)(*bufp-bufp_orig), bc, imm->sign?-1:1, d))