x86-64: fix udiv, add cqto instruction

This commit is contained in:
grischka 2009-12-19 19:14:14 +01:00
parent 1445fea582
commit dd3d4f7295
2 changed files with 8 additions and 1 deletions

View File

@ -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)

View File

@ -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) {