x86-64: fix udiv, add cqto instruction
This commit is contained in:
parent
1445fea582
commit
dd3d4f7295
2 changed files with 8 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
||||||
DEF_ASM_OP0(cwtl, 0x98)
|
DEF_ASM_OP0(cwtl, 0x98)
|
||||||
DEF_ASM_OP0(cwtd, 0x6699)
|
DEF_ASM_OP0(cwtd, 0x6699)
|
||||||
DEF_ASM_OP0(cltd, 0x99)
|
DEF_ASM_OP0(cltd, 0x99)
|
||||||
|
DEF_ASM_OP0(cqto, 0x4899)
|
||||||
DEF_ASM_OP0(int3, 0xcc)
|
DEF_ASM_OP0(int3, 0xcc)
|
||||||
DEF_ASM_OP0(into, 0xce)
|
DEF_ASM_OP0(into, 0xce)
|
||||||
DEF_ASM_OP0(iret, 0xcf)
|
DEF_ASM_OP0(iret, 0xcf)
|
||||||
|
|
|
@ -1137,7 +1137,13 @@ void gen_opi(int op)
|
||||||
r = TREG_RAX;
|
r = TREG_RAX;
|
||||||
} else {
|
} else {
|
||||||
if (op == TOK_UDIV || op == TOK_UMOD) {
|
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);
|
o(0xf0 + fr);
|
||||||
} else {
|
} else {
|
||||||
if ((vtop->type.t & VT_BTYPE) & VT_LLONG) {
|
if ((vtop->type.t & VT_BTYPE) & VT_LLONG) {
|
||||||
|
|
Loading…
Reference in a new issue