3 .type add_digits, @function
5 # Add two arrays of 64 bit digits, with carry, modifying the first argument
6 # Address at first argument %rdi is array to add and modify
7 # Address at second %rsi will be added (not modified)
8 # Third argument is counter of number of digits
9 # Result in %rax is the final result in the carry flag
10 # Exploits the fact that inc and dec do not affect the carry flag
13 movq (%rsi), %rax # Temporarily store digit from second array
14 adcq %rax, (%rdi) # Add digits in second and first array, store in first
15 dec %rdx # Decrement counter
16 jz end_loop # We are done
18 # Move to next element in the first array
27 # Move to next element in the second array