diff --git a/x86_64-asm.h b/x86_64-asm.h index c2df8223..69cd77ca 100644 --- a/x86_64-asm.h +++ b/x86_64-asm.h @@ -26,6 +26,7 @@ DEF_ASM_OP0(cwtl, 0x98) DEF_ASM_OP0(cwtd, 0x6699) DEF_ASM_OP0(cltd, 0x99) + DEF_ASM_OP0(cqto, 0x4899) DEF_ASM_OP0(int3, 0xcc) DEF_ASM_OP0(into, 0xce) DEF_ASM_OP0(iret, 0xcf) diff --git a/x86_64-gen.c b/x86_64-gen.c index e22de5c5..052bf874 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -1137,7 +1137,13 @@ void gen_opi(int op) r = TREG_RAX; } else { if (op == TOK_UDIV || op == TOK_UMOD) { - o(0xf7d231); /* xor %edx, %edx, div fr, %eax */ + if ((vtop->type.t & VT_BTYPE) & VT_LLONG) { + o(0xd23148); /* xor %rdx, %rdx */ + o(0x48 + REX_BASE(fr)); + } else { + o(0xd231); /* xor %edx, %edx */ + } + o(0xf7); /* div fr, %eax */ o(0xf0 + fr); } else { if ((vtop->type.t & VT_BTYPE) & VT_LLONG) {