t...@gmplib.org (Torbjörn Granlund) writes: > > {cout, r} = a + ~b + cin > > This is a - b - borrow, where the borrow is the complement of the > carry bit. > > Niels' definition is important as it captures the similarity with > addition. It is indeed how the instructions are described in the vendor > manuals.
And it's closer to the hardware, since this makes it clear that there's only one stage of carry propagation (~b is a totally parallel bit-by-bit inversion, while logic to constuct -b is slower and more complex), done identically as for addition. Likely using something like https://en.wikipedia.org/wiki/Kogge%E2%80%93Stone_adder. Then, the ISA could of course complement the carry flag at input and output, regardless of the rest of the hardware, like it's done on x86. But I've found the ARM convention more convenient, e.g., when writing wraparound code for special-form ECC-related primes. And, which I guess is more relevant in the sub_ddmmss context, it also means that there's little need for separate instructions for adding and subtracting constants. Regards, /Niels -- Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677. Internet email is subject to wholesale government surveillance. _______________________________________________ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs