aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--x86_64-asm.h1
-rw-r--r--x86_64-gen.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/x86_64-asm.h b/x86_64-asm.h
index c2df822..69cd77c 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 e22de5c..052bf87 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) {