GMP-汇编代码?
在哪里可以找到为 gmp-5.0.0 编写的程序的汇编代码 我使用 UBUNTU 和 G++ 编译器.. 编译代码的命令是“g++ test.cc -o outp -lgmp”
实际上我想知道内部发生的1和0的情况... 内存分配将如何发生以及如何在 RAW 位上执行操作!
Where i can find ASSEMBLY code for my program written for gmp-5.0.0
im using UBUNTU and G++ compiler..
command for compiling the code is "g++ test.cc -o outp -lgmp"
actually i want to know what happens internally in terms of 1's and 0's...
how the memory allocation will takes place and how the operations will performed on RAW bits!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
GMP 包包含一个
mpn\
文件夹,其中包含 GMP 的所有汇编代码。请参阅我的答案此处,但是,简而言之,所有 GMP 高级功能(例如mpz_...
、mpq_...
和mpf_...
)调用mpn_...
自然数运算的函数。这些“低级”函数实际上调用为大量平台(x86、ARM、sparcs、powerpcs 等)编写的高度优化的汇编代码,并且由 GMP Autotools 决定链接哪些特定代码( Autoconf 和 Automake)根据您的目标平台系统。mpn\
dir 中的代码非常不言自明。The GMP package contains a
mpn\
folder which contains all assembly code for GMP. Please, see my answer here but, in short, all GMP high level functions (likempz_...
,mpq_...
, andmpf_...
) call thempn_...
functions for operations on natural numbers. These "low-level" functions actually call highly-optimized assembly code written for a great deal of platforms (x86, ARMs, sparcs, powerpcs, etc.), and the decision on which specific code to link is done by the GMP Autotools (Autoconf and Automake) system according to your target platform. The code there inmpn\
dir is pretty self-explanatory.来自
gcc(1)
手册页:From the
gcc(1)
man page:您可以使用
-S
标志获取生成的汇编语言。请记住,这将主要包含为您的代码生成的程序集,而不是为您使用的库函数等生成的代码。 “主要”是因为它可以/将在您包含的标头中包含为内联函数生成的代码。You can get the generated assembly language using the
-S
flag. Keep in mind that this will mostly contain the assembly generated for your code, not the generated code for things like library functions you use. The "mostly" is because it can/will include code generated for inline functions in headers you've included.该代码是用 C 编写的,因此您应该查看源代码,这将是理解汇编代码的第一步(通常足以理解“原始位”发生的情况)。无论如何,都有一些内联的程序集
那么也许您可以做的是在 gdb 中运行代码并使用
disassemble
命令查看极少数特定代码的汇编代码并尝试理解它们。The code is written in C so you should look at the source code this will be a first step to understand the assembly code (usually it is enough to understand what happen with "raw bits"). There is some assembly inlined anyway
Then maybe what you could do is to run your code inside gdb and use the
disassemble
command to see the assembly code of a very few and specific peace of code and try to understand them.您可以使用 objdump 1 反汇编
libgmp
。这不会很有趣。(代码的反汇编大多只包括对 libgmp 函数的调用,除非您也反汇编 libgmp ,否则不会揭示“内部发生的情况”。)
也许您想要阅读源代码2?
You can use
objdump
1 to disassemble yourlibgmp
. It won't be interesting.(And the disassembly of your code mostly just include a call to the
libgmp
function which won't reveal "what happens internally" unless you disassemblelibgmp
as well.)Perhaps you want to read the source code2 instead?