I am trying to add two numbers in C. My code is
#define type unsigned
type add(type a, type b) {
return a + b;
}
Code corresponding to above code in assembly makes use of a single add instruction (https://godbolt.org/ & ARM GCC 8.3.1). However when I changed the type
to unsigned long long
, code was bit obfuscated to understand; But, I believe it makes use of some ldm
and then asks hardware to add complete vectors (or arrays). Similarly my next question was: is it possible to add two numbers where digits count in each number will be in the order of 1000s? It isn't hard to design a function and make it work, and I found many codes on internet which do this. But, I think compiler writes better code than us,
- so are there any gcc built-in functions which can do this job?
- In fact, does gcc provide such functions for all the 5 integer arithmetic operations?