Arm/add64

From ASMBits

arm/bits2Previous

Write a function that returns the sum of its two parameters. The parameters and return values are both 64-bit integers. 64-bit operands are passed in two consecutive registers. Thus, the first parameter is in r0 and r1, while the second parameter is in r2 and r3, with the return value returned in r0 and r1.

long long add64 (long long a, long long b);

Expected solution length: Around 3 lines.

Sample Input

(1, 1)

Sample Output

2 

The difference between regular addition and big-integer addition is that you need to detect the carry-out from the low-order adder and feed that to the carry-in of the high-order adder (much like a ripple-carry adder). ARM's carry flag can be used for that purpose, using the adds and adc instructions.

Write your solution here

Upload a source file...