Skip to content

Commit 43c35de

Browse files
committed
changes made for x86 32 bits system
1 parent 7fc002d commit 43c35de

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

std/math/exponential.d

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -860,33 +860,33 @@ Unqual!(Largest!(F, H)) powmod(F, G, H)(F x, G n, H m) if (isUnsigned!F && isUns
860860
return low;
861861
}
862862
else version(LDC) {
863-
// LDC/GDC: Use GCC-style inline assembly
864-
ulong low, high;
863+
uint low, high;
865864

866-
asm pure @trusted nothrow @nogc{
867-
"mulq %[b]"
868-
: "=a"(low), "=d"(high)
869-
: [a] "a"(a), [b] "r"(b)
870-
: "cc";
871-
};
865+
asm pure @trusted nothrow @nogc {
866+
"mull %2"
867+
: "=a"(low), "=d"(high)
868+
: "r"(b), "0"(a) // Ensure a is in eax
869+
: "cc";
870+
};
872871

873-
if (high >= c) {
874-
high %= c;
875-
}
872+
if (high >= c) {
873+
high %= c;
874+
}
876875

877-
if (high == 0) {
878-
return low % c;
879-
}
876+
if (high == 0) {
877+
return low % c;
878+
}
880879

881-
asm pure @trusted nothrow @nogc {
882-
"divq %[c]"
883-
: "=a"(low), "=d"(high)
884-
: [a] "a"(low), "d"(high), [c] "r"(c)
885-
: "cc";
886-
};
880+
asm pure @trusted nothrow @nogc {
881+
"divl %2"
882+
: "=a"(low), "=d"(high)
883+
: "r"(c), "0"(low), "1"(high) // Ensure correct register allocation
884+
: "cc";
885+
};
886+
887+
return low;
888+
}
887889

888-
return low;
889-
}
890890
else {
891891
// Use 64-bit type for the calculation
892892
ulong result = (cast(ulong)a * cast(ulong)b) % c;
@@ -895,7 +895,7 @@ Unqual!(Largest!(F, H)) powmod(F, G, H)(F x, G n, H m) if (isUnsigned!F && isUns
895895

896896
}
897897
else static if (T.sizeof == 4) {
898-
version (D_InlineAsm_X86) {
898+
version (D_InlineAsm_X86_64) {
899899
uint low = void;
900900
uint high = void;
901901

0 commit comments

Comments
 (0)