aboutsummaryrefslogtreecommitdiff
path: root/lib/std/special/compiler_rt/aulldiv.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-09-26 01:54:45 -0400
committerGitHub <noreply@github.com>2019-09-26 01:54:45 -0400
commit68bb3945708c43109c48bda3664176307d45b62c (patch)
treeafb9731e10cef9d192560b52cd9ae2cf179775c4 /lib/std/special/compiler_rt/aulldiv.zig
parent6128bc728d1e1024a178c16c2149f5b1a167a013 (diff)
parent4637e8f9699af9c3c6cf4df50ef5bb67c7a318a4 (diff)
downloadzig-68bb3945708c43109c48bda3664176307d45b62c.tar.gz
zig-68bb3945708c43109c48bda3664176307d45b62c.zip
Merge pull request #3315 from ziglang/mv-std-lib
Move std/ to lib/std/
Diffstat (limited to 'lib/std/special/compiler_rt/aulldiv.zig')
-rw-r--r--lib/std/special/compiler_rt/aulldiv.zig55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/std/special/compiler_rt/aulldiv.zig b/lib/std/special/compiler_rt/aulldiv.zig
new file mode 100644
index 0000000000..d99bc94ff5
--- /dev/null
+++ b/lib/std/special/compiler_rt/aulldiv.zig
@@ -0,0 +1,55 @@
+pub nakedcc fn _aulldiv() void {
+ @setRuntimeSafety(false);
+ asm volatile (
+ \\.intel_syntax noprefix
+ \\
+ \\ push ebx
+ \\ push esi
+ \\ mov eax,dword ptr [esp+18h]
+ \\ or eax,eax
+ \\ jne L1
+ \\ mov ecx,dword ptr [esp+14h]
+ \\ mov eax,dword ptr [esp+10h]
+ \\ xor edx,edx
+ \\ div ecx
+ \\ mov ebx,eax
+ \\ mov eax,dword ptr [esp+0Ch]
+ \\ div ecx
+ \\ mov edx,ebx
+ \\ jmp L2
+ \\ L1:
+ \\ mov ecx,eax
+ \\ mov ebx,dword ptr [esp+14h]
+ \\ mov edx,dword ptr [esp+10h]
+ \\ mov eax,dword ptr [esp+0Ch]
+ \\ L3:
+ \\ shr ecx,1
+ \\ rcr ebx,1
+ \\ shr edx,1
+ \\ rcr eax,1
+ \\ or ecx,ecx
+ \\ jne L3
+ \\ div ebx
+ \\ mov esi,eax
+ \\ mul dword ptr [esp+18h]
+ \\ mov ecx,eax
+ \\ mov eax,dword ptr [esp+14h]
+ \\ mul esi
+ \\ add edx,ecx
+ \\ jb L4
+ \\ cmp edx,dword ptr [esp+10h]
+ \\ ja L4
+ \\ jb L5
+ \\ cmp eax,dword ptr [esp+0Ch]
+ \\ jbe L5
+ \\ L4:
+ \\ dec esi
+ \\ L5:
+ \\ xor edx,edx
+ \\ mov eax,esi
+ \\ L2:
+ \\ pop esi
+ \\ pop ebx
+ \\ ret 10h
+ );
+}