Zooming is now sligtly less slow.
[ipdf/code.git] / src / mul_digits_asm.s
1 .section .text
2 .globl mul_digits
3 .type mul_digits, @function
4
5 # Multiply an array of 64 bit digits by *one* 64 bit digit, modifies the array in place
6 mul_digits:
7         movq %rdx, %rcx # rdx is reserved for mulq, use rcx as counter
8         movq $0, %r12 # Overflow register
9         loop:
10                 movq %rsi, %rax # Value to multiply in %rax
11                 mulq (%rdi) # Multiply, stored in %rdx:%rax (ie: we get TWO digits)
12                 
13                 # Add overflow from previous operation
14                 add %r12, %rax
15                 # Upper digit gets saved as next overflow
16                 movq %rdx, %r12
17                 
18                 # Lower digit goes in current array position
19                 movq %rax, (%rdi)
20                 
21                 dec %rcx # Decrement counter
22                 jz end_loop # We are done
23                 
24                 # Move to next element in the array
25                 leaq 8(,%rdi,1), %rdi
26                 jmp loop # Repeat
27                 
28         end_loop:
29         end:
30                 movq %r12, %rax # Return overflow
31                 ret # We are done

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