diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2014-08-20 00:42:42 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2014-08-20 00:42:42 +0200 |
commit | daa8b559b6bb7ab05e3922a210c1ae5ade1848de (patch) | |
tree | 706ddb25f5ada5bfe71cbd4ebabcad334adb864a | |
parent | 0f720a83d5f66d16354cae14c842c5264fda22b6 (diff) | |
parent | 5b326269c3eb5d268c81152155acfa4e53274cd9 (diff) | |
download | Nim-daa8b559b6bb7ab05e3922a210c1ae5ade1848de.tar.gz |
Merge pull request #1495 from barcharcraz/fix1491
fixed #1491
-rw-r--r-- | lib/system/arithm.nim | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/system/arithm.nim b/lib/system/arithm.nim index bb15360fd..7672947cd 100644 --- a/lib/system/arithm.nim +++ b/lib/system/arithm.nim @@ -114,63 +114,69 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc): proc addInt(a, b: int): int {.compilerProc, asmNoStackFrame.} = # a in eax, and b in edx asm """ - mov eax, `a` - add eax, `b` + mov eax, ecx + add eax, edx jno theEnd call `raiseOverflow` theEnd: + ret """ proc subInt(a, b: int): int {.compilerProc, asmNoStackFrame.} = asm """ - mov eax, `a` - sub eax, `b` + mov eax, ecx + sub eax, edx jno theEnd call `raiseOverflow` theEnd: + ret """ proc negInt(a: int): int {.compilerProc, asmNoStackFrame.} = asm """ - mov eax, `a` + mov eax, ecx neg eax jno theEnd call `raiseOverflow` theEnd: + ret """ proc divInt(a, b: int): int {.compilerProc, asmNoStackFrame.} = asm """ - mov eax, `a` - mov ecx, `b` + mov eax, ecx + mov ecx, edx xor edx, edx idiv ecx jno theEnd call `raiseOverflow` theEnd: + ret """ proc modInt(a, b: int): int {.compilerProc, asmNoStackFrame.} = asm """ - mov eax, `a` - mov ecx, `b` + mov eax, ecx + mov ecx, edx xor edx, edx idiv ecx jno theEnd call `raiseOverflow` theEnd: mov eax, edx + ret """ proc mulInt(a, b: int): int {.compilerProc, asmNoStackFrame.} = asm """ - mov eax, `a` - mov ecx, `b` + mov eax, ecx + mov ecx, edx xor edx, edx imul ecx jno theEnd call `raiseOverflow` theEnd: + ret """ elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)): |