开发者

GMP ..binary execution

In GMP library....

how does internal execution of operations on integers ll be done?? like 6=0110,4=0100..and 6+4=开发者_JAVA技巧 0110+0100.. what happens in case of multiplications,division and other operations!?? how does it controls overflow bits and other things ...


Most basic multiple-precision routines are written in assembly code and take advantage of specific CPU instructions.

For addition, the basic instruction is "ADD-with-Carry". This instruction will add the contents of two CPU registers and the carry bit, and then saves the result in a register and sets the carry bit if there was overflow. To add two multiple-precision numbers, the carry bit is cleared, then the first word (usually a C "unsigned int" or "unsigned long") in each multiple- precision value is added, the result saved, and the carry bit set for the next loop. The details are in handling different sized inputs, etc.

For multiplication, the basic instruction "MULT" just multiplies two registers and stores the upper half of the result in one CPU register and the lower half of the result in another CPU register.

For details on how it is actually done on a CPU, you'll need to research the CPU's instruction set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜