From 7e0731ebdde687e59ed90de1534b57525903977a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 8 Oct 2007 17:13:55 -0600 Subject: [PATCH] various bugfixes involving longs --- makefile | 2 +- src/compile.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 4d8cf04e1f..ae82a6c8a1 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -#MAKEFLAGS = -s +MAKEFLAGS = -s arch = $(shell uname -m) ifeq ($(arch),i586) diff --git a/src/compile.cpp b/src/compile.cpp index c5dfefc02d..35daee8124 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -1010,6 +1010,11 @@ class Assembler { code.append(0x99); } + void cqo() { + rex(); + cdq(); + } + void imul4(Register src, unsigned srcOffset, Register dst) { code.append(0x0f); offsetInstruction(0xaf, 0, 0x40, 0x80, dst, src, srcOffset); @@ -1048,6 +1053,10 @@ class Assembler { code.append(0xd8 | reg); } + void int3() { + code.append(0xcc); + } + Buffer code; Buffer jumps; }; @@ -2099,10 +2108,10 @@ class Compiler: public Assembler { Label greater(this); if (BytesPerWord == 8) { - popLong(rdx); popLong(rax); + popLong(rcx); - cmp(rax, rdx); + cmp(rax, rcx); jl(less); jg(greater); @@ -2118,8 +2127,8 @@ class Compiler: public Assembler { next.mark(); } else { - popLong(rcx, rbx); popLong(rax, rdx); + popLong(rcx, rbx); cmp(rdx, rbx); jl(less); @@ -2145,8 +2154,9 @@ class Compiler: public Assembler { case ldiv_: if (BytesPerWord == 8) { - popLong(rax); popLong(rcx); + popLong(rax); + cqo(); Assembler::idiv(rcx); pushLong(rax); } else { @@ -2218,6 +2228,7 @@ class Compiler: public Assembler { if (BytesPerWord == 8) { popLong(rax); popLong(rcx); + cqo(); Assembler::idiv(rcx); pushLong(rdx); } else {