GMP ..二进制执行

发布于 2024-08-19 12:46:34 字数 124 浏览 4 评论 0原文

在 GMP 库中......

整数运算的内部执行如何完成? 就像 6=0110,4=0100.. 和 6+4=0110+0100.. 如果进行乘法、除法和其他运算会发生什么?? 它如何控制溢出位和其他东西......

In GMP library....

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩耳倾听 2024-08-26 12:46:34

大多数基本的多精度例程都是用汇编代码编写的,并利用特定的 CPU 指令。

对于加法,基本指令是“ADD-with-Carry”。该指令将两个CPU寄存器的内容和进位位相加,然后将结果保存到寄存器中,如果发生溢出则设置进位位。要添加两个多精度数,请清除进位位,然后将每个多精度值中的第一个字(通常是 C“unsigned int”或“unsigned long”)相加,保存结果,并设置进位位用于下一个循环。细节在于处理不同大小的输入等。

对于乘法,基本指令“MULT”只是将两个寄存器相乘,并将结果的上半部分存储在一个CPU寄存器中,将结果的下半部分存储在另一个CPU寄存器中。

有关它如何在 CPU 上实际完成的详细信息,您需要研究 CPU 的指令集。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文