c语言常用api函数,高手过来,关于API函数和C语言的库函数

刚才在网上搜了一下,连SQRT()都是用汇编语言编的,何况是这种跟内存打交道的函数!

在borland 的c++ builder 6 中带的

;[]-----------------------------------------------------------------[]

;| SQRT.ASM -- square root function |

;[]-----------------------------------------------------------------[]

;

; C/C++ Run Time Library - Version 11.0

;

; Copyright (c) 1991, 2002 by Borland Software Corporation

; All Rights Reserved.

;

; $Revision: 9.3 $

;----------------------------------------------------------------------

; function(s)

; sqrt - calculates square root

;----------------------------------------------------------------------

include RULES.ASI

include _MATH.INC

; Segments Definitions

Header@

;----------------------------------------------------------------------

; External and local variables

Data_Seg@

NANSQRT dw 0,0,0020H, 07FF8H

Data_EndS@

;--------------------------------------------------------------------------

;

;Name sqrt - calculates square root

;

;Usage double sqrt (double x);

;

;Prototype in math.h

;

;Description sqrt calculates the square root of input value.

;

;Return value sqrt returns the square root of input value.

; If the input value is lees than 0, sqrt returns 0 and set

; errno to

; EDOM Domain error

;---------------------------------------------------------------------------

Code_Seg@

Func@ sqrt, _EXPFUNC, _RTLENTRY,

Link@

FLD x.double

mov ax, x [6]

shl ax, 1

jz sqrt_zero

jc sqrt_imaginary

FSQRT

sqrt_zero: ; zero = sqrt (zero)

sqrt_end:

Unlink@

Return@

sqrt_imaginary:

FSTP st (0) ; pop x from stack

; return __matherr (DOMAIN, “sqrt“, &x, NULL, *((double *) NANSQRT));

matherr DOMAIN, sqrt, x, NULL, NANSQRT

jmp sqrt_end

EndFunc@ sqrt

Code_Ends@

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值