开发者

GMP ..binary execution

开发者 https://www.devze.com 2022-12-18 02:17 出处:网络
In GMP library.... how does internal execution of operations on integers ll be done?? like6=0110,4=0100..and

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

精彩评论

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