简体   繁体   English

如何在Linux的NASM中正确使用C函数“ Exp”?

[英]How can the C function “Exp” be properly used in NASM for Linux?

I am trying to implement the C function "exp" in NASM for Linux. 我正在尝试在NASM for Linux中实现C函数“ exp”。 The function takes a double value x, and returns a double value r = e^x, where e is Euler's Number. 该函数采用双精度值x,并返回双精度值r = e ^ x,其中e是欧拉数。 This is my implementation: 这是我的实现:

extern exp

SECTION .bss

    doubleActual: resq 1
    doubleX: resq 1

SECTION .text

    main:
    ;some other code here

    ;calculate actual result
    push doubleActual ; place to store result
    push doubleX ;give the function what x is.
    call exp
    add esp, 8

On compile attempt, i get the following: 在编译尝试时,我得到以下信息:

hw7_3.o: In function `termIsLess':
hw7_3.asm:(.text+0xf9): undefined reference to `exp'

This is referring to when i actually call exp, which is odd, because "extern exp" seems to work just fine. 这是指我实际调用exp的时间,这很奇怪,因为“ extern exp”似乎可以正常工作。 What am i doing incorrectly? 我在做什么错?

via http://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_17.html .... 通过http : //www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_17.html ...。

I need to do the following with gcc: 我需要对gcc执行以下操作:

gcc -m32 name.o -lm -o name

The "-lm" tag is a shortcut to link the C math library, which is separate from the standard library. “ -lm”标记是链接C数学库的快捷方式,该库与标准库分开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM