History

x86-64: fix udiv, add cqto instruction

grischka committed 16 years ago

Commit dd3d4f71 parent 1445fea2 files · +8 −1Browse files

Unified · Split

2 files
  1. x86_64-asm.h +1 −0
  2. x86_64-gen.c +7 −1
x86_64-asm.h+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 DEF_ASM_OP0(cwtl, 0x98)
2727 DEF_ASM_OP0(cwtd, 0x6699)
2828 DEF_ASM_OP0(cltd, 0x99)
29+ DEF_ASM_OP0(cqto, 0x4899)
2930 DEF_ASM_OP0(int3, 0xcc)
3031 DEF_ASM_OP0(into, 0xce)
3132 DEF_ASM_OP0(iret, 0xcf)
x86_64-gen.c+7−1
@@ -1137,7 +1137,13 @@ void gen_opi(int op) · 1136 unmodified lines
11371137 r = TREG_RAX;
11381138 } else {
11391139 if (op == TOK_UDIV || op == TOK_UMOD) {
1140− o(0xf7d231); /* xor %edx, %edx, div fr, %eax */
1140+ if ((vtop->type.t & VT_BTYPE) & VT_LLONG) {
1141+ o(0xd23148); /* xor %rdx, %rdx */
1142+ o(0x48 + REX_BASE(fr));
1143+ } else {
1144+ o(0xd231); /* xor %edx, %edx */
1145+ }
1146+ o(0xf7); /* div fr, %eax */
11411147 o(0xf0 + fr);
11421148 } else {
11431149 if ((vtop->type.t & VT_BTYPE) & VT_LLONG) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t