Good question!
The following code prints out that you want to use GCC -O or higher without resorting to assembler:
uint32_t a, b;
uint64_t c;
...
c = (uint64_t) a * (uint64_t) b;
or, if you think you need to use asm for a specific machine, you can go:
uint32_t a, b;
uint64_t c;
asm ("umull% Q0,% R0,% 1,% 2": "= r" (c): "r" (a), "r" (b));
c the register name is the first of the pair of registers, and% Q and% R select the lower and upper 32-bit registers of the pair. For an example, see Gcc / config / arm / arm.md β umulsidi3.
However, if you can stay in C, this gives the optimizer a chance to do more and better for readers of your program.
source share