The view size is not 640x480 and hasn't been for a long time
[ipdf/code.git] / src / div_digits_asm.S
1 .section .text
2 .globl div_digits
3 .type div_digits, @function
4
5 #ifdef __x86_64__
6
7 # div_digits(digits, div, size, res)
8 # divides an arbint in digits by uint64 div into res, returns remainder
9 # res may alias digits
10 # digits = rdi, div = rsx, size = rdx, res = rcx,
11 div_digits:
12         movq %rdx, %r8
13         leaq -8(%rdi,%r8,8), %rdi       # We want to point to the end of the buffer (LSB)
14         leaq -8(%rcx,%r8,8), %rcx       # We want to point to the end of the buffer (LSB)
15         movq $0, %rdx
16 loop:
17         movq (%rdi), %rax
18         divq %rsi                       # rdx:rax/rsi => rax, rdx:rax%rsi => rdx
19         movq %rax, (%rcx)
20         dec %r8
21         leaq -8(%rdi), %rdi
22         leaq -8(%rcx), %rcx
23         jnz loop
24 end:
25         movq %rdx, %rax                 # return the remainder
26         ret
27         
28 #else
29
30 div_digits:
31         ret
32
33 #endif

UCC git Repository :: git.ucc.asn.au