3 ms·
What about "addWithCarry", ie. ADC? Getting the carry bit seems only half the battle. I'd not seen this compiler tool before so had a quick play around with it.
by globular-toast 6y ago
What about "addWithCarry", ie. ADC? Getting the carry bit seems only half the battle. I'd not seen this compiler tool before so had a quick play around with it. It's very cool! But I couldn't get a compiler to recognise it could use ADC.
- haberman 6y agoThis seems to work. The compiler has to see the previous add to know what is in the carry flag. #include <stdint.h> uint64_t addWithCarry(uint64_t x, uint64_t y, uint64_t z) { return x + y + (y + z < y); } Output here: https://godbolt.org/z/zfP7PnGcs https://godbolt.org/z/zfP7PnGcs