In article , "Wilco Dijkstra" writes: |> |> > Not that I can see. How many have a 64x64->128 multiply and a |> > 128/64->64,64 quotient, remainder? |> |> Widening multiplies are quite common on CPUs, division is far less |> common (ie. on RISC), especially the narrowing form. Luckily you don't |> need a division primitive for multi precision arithmetic.
No, you don't. You DO, however, need it for efficient, relatively short, multiple precision arithmetic - such as is very common, especially for floating-point emulation.
And you are wrong that widening multiplies are quite common for the largest efficient integer sizes. It gains you very little having to drop to a size down in order to get them.
|> > |> Using add with carry is easy in C, various compilers can detect it: |> >
|> > Some compilers may be able to, IF you use a code form that they can |> > recognise; but, if they don't document that and exactly what code |> > forms are acceptable, you are just hoping. |> |> The idioms for rotate, widening multiplies, carry, multiply+accumulate, |> divison+modulo and so on are pretty standard. It is trivial to recognise |> the various forms, eg. a + b a + b both test the carry flag.
Ah. Perhaps I know rather more idioms than you do.
|> > And, in any case, that is not "in C" - it is "in Intel C" or "in gcc" |> > etc. There is no way of doing it in standard or portable C, let alone |> > standard AND portable C. |> |> Actually these idioms are both standard AND portable (the code I showed |> works on all compilers irrespectively of integer size or whether the target |> even has a carry flag!). On the other hand, inline assembler is non-standard |> and not portable between different compilers for the same architecture.
That code will work only for unsigned values and, even then, only if all operands are the same precision. It will NOT generate code that uses the carry bit at all reliably, even on Intel.
I have just checked gcc and Intel - neither do it by default, though they might if I found the right compiler option.
Regards, Nick Maclaren.