程序集x86中的Math.h库函数? [英] Math.h library functions in assembly x86?
问题描述
我试图将在Linux(fedora 9)下编写的C代码转换为汇编x86代码,但是,我在Math.h函数中遇到问题.该库中的功能(例如ceil,floor,log,log10,pow)在程序集x86中未定义.您能帮我解决这个问题吗?
I tried to convert C code that is written under Linux (fedora 9) to assembly x86 code, however, I have problem in a Math.h functions. The functions in this library such as ceil, floor, log, log10, pow are undefined in the assembly x86. Can you please help me to solve this problem?
谢谢.
推荐答案
大多数库函数不会用汇编语言定义,至少在直接映射到ADD
指令的加法运算符意义上不是这样.如果要以汇编形式重写该库,则必须使用处理器可用的任何功能来实现该功能.大多数库函数将需要单独的汇编语言子例程,而不仅仅是单个操作.解决此问题的最简单方法是使各个库子例程独立运行,然后将它们合并到较大的程序中.
Most library functions won't be defined in assembly language, at least not in the sense of the addition operator directly mapping to the ADD
instruction. If you want to re-write the library in assembly, you'll have to implement the function using whatever capabilities that your processor has available. Most library functions will require a separate assembly language subroutine, not just a single operation. The easiest way to approach this is to get the individual library subroutines working in isolation, then incorporate them into the larger program.
您可以编译C代码并检查反汇编后的输出,但是要当心编译器的优化,这些优化可能会使输出难以为人所知.
You can compile the C code and examine the disassembled output, but beware of compiler optimizations that can make the output hard for a human to follow.
请问这个任务的目的是什么?由于编译器本质上是C到汇编语言的翻译器,因此几乎不需要手动执行此操作.这是家庭作业吗?
May I ask what the purpose is behind this task? Since a compiler is essentially a C to assembly-language translator, there's rarely a need to do this by hand. Is this homework?
这篇关于程序集x86中的Math.h库函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!