git.ucc.asn.au
/
ipdf
/
code.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b056196
)
now with fewer midnight-isms
author
David Gow
<
[email protected]
>
Sun, 6 Jul 2014 01:46:52 +0000
(09:46 +0800)
committer
David Gow
<
[email protected]
>
Sun, 6 Jul 2014 01:46:52 +0000
(09:46 +0800)
src/div_digits_asm.s
patch
|
blob
|
history
diff --git
a/src/div_digits_asm.s
b/src/div_digits_asm.s
index
b11dd92
..
1ebf86f
100644
(file)
--- a/
src/div_digits_asm.s
+++ b/
src/div_digits_asm.s
@@
-2,27
+2,25
@@
.globl div_digits
.type div_digits, @function
.globl div_digits
.type div_digits, @function
-# div_digits(digits, div, size, res
, rem
)
-# divides an arbint in digits by uint64 div into res
with remainder rem
-#
Either res or rem
may alias digits
-# digits = rdi, div = rsx, size = rdx, res = rcx,
rem = r8
+# div_digits(digits, div, size, res)
+# divides an arbint in digits by uint64 div into res
, returns remainder
+#
res
may alias digits
+# digits = rdi, div = rsx, size = rdx, res = rcx,
div_digits:
div_digits:
- movq %rdx, %r9
- leaq -8(%rdi,%r9,8), %rdi # We want to point to the end of the buffer (LSB)
- leaq -8(%rcx,%r9,8), %rcx # We want to point to the end of the buffer (LSB)
- leaq -8(%r8,%r9,8), %r8 # We want to point to the end of the buffer (LSB)
+ movq %rdx, %r8
+ leaq -8(%rdi,%r8,8), %rdi # We want to point to the end of the buffer (LSB)
+ leaq -8(%rcx,%r8,8), %rcx # We want to point to the end of the buffer (LSB)
movq $0, %rdx
loop:
movq (%rdi), %rax
divq %rsi # rdx:rax/rsi => rax, rdx:rax%rsi => rdx
movq %rax, (%rcx)
movq $0, %rdx
loop:
movq (%rdi), %rax
divq %rsi # rdx:rax/rsi => rax, rdx:rax%rsi => rdx
movq %rax, (%rcx)
- movq %rdx, (%r8)
- dec %r9
+ dec %r8
leaq -8(%rdi), %rdi
leaq -8(%rcx), %rcx
leaq -8(%rdi), %rdi
leaq -8(%rcx), %rcx
- leaq -8(%r8), %r8
jnz loop
end:
jnz loop
end:
+ movq %rdx, %rax # return the remainder
ret
ret
UCC
git Repository :: git.ucc.asn.au