home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2241 < prev    next >
Internet Message Format  |  1990-12-28  |  11KB

  1. From: glenn@extro.ucc.su.OZ.AU (Glenn Geers)
  2. Newsgroups: alt.sources
  3. Subject: 80386 alternative math library part04/04
  4. Message-ID: <1990Dec7.220328.920@metro.ucc.su.OZ.AU>
  5. Date: 7 Dec 90 22:03:28 GMT
  6.  
  7. Submitted-by: glenn@trantor
  8. Archive-name: libfpu/part04
  9.  
  10. #!/bin/sh
  11. # This is part 04 of libfpu
  12. # ============= pow.s ==============
  13. if test -f 'pow.s' -a X"$1" != X"-c"; then
  14.     echo 'x - skipping pow.s (File already exists)'
  15. else
  16. echo 'x - extracting pow.s (Text)'
  17. sed 's/^X//' << 'SHAR_EOF' > 'pow.s' &&
  18. /*
  19. ** This file is part of the alternative 80386 math library and is
  20. ** covered by the GNU General Public license with my modification
  21. ** as noted in the README file that accompanied this file.
  22. **
  23. ** This file started life as a C implemenation of pow, it then evolved
  24. ** into an embeded asm version (with some C) and finally, all assembler.
  25. ** It's actually hacked assembler produced by gcc.
  26. **
  27. ** Copyright 1990 G. Geers
  28. **
  29. */
  30. X
  31. .text
  32. .LC0:
  33. X    .ascii "pow: DOMAIN error\12\0"
  34. X    .align 4
  35. .LC1:
  36. X    .double 0d0.00000000000000000000e+00
  37. X    .align 4
  38. .LC2:
  39. X    .double 0d1.00000000000000000000e+00
  40. X    .align 4
  41. .globl pow
  42. pow:
  43. X    pushl %ebp
  44. X    movl %esp,%ebp
  45. X    subl $28,%esp
  46. X    pushl %edi
  47. X    pushl %esi
  48. X    pushl %ebx
  49. X    movl 16(%ebp),%esi
  50. X    movl 20(%ebp),%edi
  51. X    movl $0,-4(%ebp)
  52. X    movl $1,%ebx
  53. X    fldl 8(%ebp)
  54. X    ftst
  55. X    fstp %st(0)
  56. X    fnstsw %ax
  57. X    sahf
  58. X    jae .L2
  59. X    movl %ebx,-4(%ebp)
  60. X    pushl %edi
  61. X    pushl %esi
  62. /**/
  63. X    fldl 16(%ebp)
  64. X
  65. X    fstcw -8(%ebp)
  66. X    fstcw -12(%ebp)
  67. X    orw $0x0400, -12(%ebp)
  68. X    fldcw -12(%ebp)
  69. X
  70. X    frndint
  71. X    fldcw -8(%ebp)
  72. /**/
  73. X    fstpl -16(%ebp)
  74. X    pushl %edi
  75. X    pushl %esi
  76. X    fldl (%esp) 
  77. X    addl $8,%esp
  78. X    fsubl -16(%ebp)
  79. X    fstpl -16(%ebp)
  80. X    addl $8,%esp
  81. X    fldl -16(%ebp)
  82. X    ftst
  83. X    fstp %st(0)
  84. X    fnstsw %ax
  85. X    sahf
  86. X    je .L3
  87. X    movl $33,errno
  88. X    pushl $.LC0
  89. X    pushl $_iob+32
  90. X    call fprintf
  91. X    fldl .LC1
  92. X    jmp .L1
  93. X    .align 4
  94. .L3:
  95. X    pushl %edi
  96. X    pushl %esi
  97. /**/
  98. X    fldl    16(%ebp)
  99. X    fistpl    -8(%ebp)
  100. X    movl    -8(%ebp),%eax
  101. /**/
  102. X    testl %eax,%eax
  103. X    jge .L5
  104. X    incl %eax
  105. .L5:
  106. X    andl $-2,%eax
  107. X    movl -8(%ebp),%ecx
  108. X    subl %eax,%ecx
  109. X    movl %ecx,%eax
  110. X    testl %eax,%eax
  111. X    je .L2
  112. X    xorl %ebx,%ebx
  113. .L2:
  114. X    fldl 8(%ebp)
  115. X    ftst
  116. X    fstp %st(0)
  117. X    fnstsw %ax
  118. X    sahf
  119. X    jne .L6
  120. X    pushl %edi
  121. X    pushl %esi
  122. X    fldl (%esp) 
  123. X    addl $8,%esp
  124. X    ftst
  125. X    fstp %st(0)
  126. X    fnstsw %ax
  127. X    sahf
  128. X    je .L6
  129. X    fldl .LC1
  130. X    jmp .L1
  131. X    .align 4
  132. .L6:
  133. X    pushl %edi
  134. X    pushl %esi
  135. X    fldl (%esp) 
  136. X    addl $8,%esp
  137. X    ftst
  138. X    fstp %st(0)
  139. X    fnstsw %ax
  140. X    sahf
  141. X    jne .L8
  142. X    fldl .LC2
  143. X    jmp .L1
  144. X    .align 4
  145. .L8:
  146. /APP
  147. X    fldl 16(%ebp)
  148. X    fldl 8(%ebp)
  149. /NO_APP
  150. X    cmpl $0,-4(%ebp)
  151. X    je .L10
  152. /APP
  153. X    fchs
  154. /NO_APP
  155. .L10:
  156. /APP
  157. X    fyl2x
  158. X    fstl %st(1)
  159. X    frndint
  160. X    fstl %st(2)
  161. X    fsubrp
  162. X    f2xm1
  163. X    fld1
  164. X    faddp
  165. X    fscale
  166. /NO_APP
  167. X    testl %ebx,%ebx
  168. X    jne .L1
  169. /APP
  170. X    fchs
  171. /NO_APP
  172. .L1:
  173. X    leal -28(%ebp),%esp
  174. X    popl %ebx
  175. X    popl %esi
  176. X    popl %edi
  177. X    leave
  178. X    ret
  179. SHAR_EOF
  180. chmod 0644 pow.s ||
  181. echo 'restore of pow.s failed'
  182. Wc_c="`wc -c < 'pow.s'`"
  183. test 2128 -eq "$Wc_c" ||
  184.     echo 'pow.s: original size 2128, current size' "$Wc_c"
  185. fi
  186. # ============= rint.s ==============
  187. if test -f 'rint.s' -a X"$1" != X"-c"; then
  188.     echo 'x - skipping rint.s (File already exists)'
  189. else
  190. echo 'x - extracting rint.s (Text)'
  191. sed 's/^X//' << 'SHAR_EOF' > 'rint.s' &&
  192. /*
  193. ** This file is part of the alternative 80386 math library and is
  194. ** covered by the GNU General Public license with my modification
  195. ** as noted in the README file that accompanied this file.
  196. **
  197. ** Copyright 1990 G. Geers
  198. **
  199. */
  200. X
  201. X    .align 4
  202. X    .globl rint
  203. rint:
  204. X    pushl %ebp
  205. X    movl %esp,%ebp
  206. X    
  207. X    fldl 8(%ebp)
  208. X    frndint
  209. X
  210. X    leave
  211. X    ret
  212. SHAR_EOF
  213. chmod 0644 rint.s ||
  214. echo 'restore of rint.s failed'
  215. Wc_c="`wc -c < 'rint.s'`"
  216. test 326 -eq "$Wc_c" ||
  217.     echo 'rint.s: original size 326, current size' "$Wc_c"
  218. fi
  219. # ============= scalb.s ==============
  220. if test -f 'scalb.s' -a X"$1" != X"-c"; then
  221.     echo 'x - skipping scalb.s (File already exists)'
  222. else
  223. echo 'x - extracting scalb.s (Text)'
  224. sed 's/^X//' << 'SHAR_EOF' > 'scalb.s' &&
  225. /*
  226. ** This file is part of the alternative 80386 math library and is
  227. ** covered by the GNU General Public license with my modification
  228. ** as noted in the README file that accompanied this file.
  229. **
  230. ** Copyright 1990 G. Geers
  231. **
  232. */
  233. X
  234. X    .align 4
  235. X    .globl scalb
  236. scalb:
  237. X    pushl %ebp
  238. X    movl %esp,%ebp
  239. X    
  240. X    fildl 16(%ebp)
  241. X    fldl 8(%ebp)
  242. X    fscale
  243. X
  244. X    leave
  245. X    ret
  246. SHAR_EOF
  247. chmod 0644 scalb.s ||
  248. echo 'restore of scalb.s failed'
  249. Wc_c="`wc -c < 'scalb.s'`"
  250. test 343 -eq "$Wc_c" ||
  251.     echo 'scalb.s: original size 343, current size' "$Wc_c"
  252. fi
  253. # ============= setcont.s ==============
  254. if test -f 'setcont.s' -a X"$1" != X"-c"; then
  255.     echo 'x - skipping setcont.s (File already exists)'
  256. else
  257. echo 'x - extracting setcont.s (Text)'
  258. sed 's/^X//' << 'SHAR_EOF' > 'setcont.s' &&
  259. /*
  260. ** This file is part of the alternative 80386 math library and is
  261. ** covered by the GNU General Public license with my modification
  262. ** as noted in the README file that accompanied this file.
  263. **
  264. ** Copyright 1990 G. Geers
  265. **
  266. */
  267. X
  268. X    .align 4
  269. X    .globl setcont
  270. X
  271. setcont:
  272. X    pushl %ebp
  273. X    movl %esp, %ebp
  274. X    subl $4, %esp
  275. X
  276. X    fnstcw -8(%ebp)
  277. X    movw -8(%ebp), %ax
  278. X    fldcw 8(%ebp)
  279. X
  280. X    leave
  281. X    ret
  282. SHAR_EOF
  283. chmod 0644 setcont.s ||
  284. echo 'restore of setcont.s failed'
  285. Wc_c="`wc -c < 'setcont.s'`"
  286. test 377 -eq "$Wc_c" ||
  287.     echo 'setcont.s: original size 377, current size' "$Wc_c"
  288. fi
  289. # ============= setinternal.s ==============
  290. if test -f 'setinternal.s' -a X"$1" != X"-c"; then
  291.     echo 'x - skipping setinternal.s (File already exists)'
  292. else
  293. echo 'x - extracting setinternal.s (Text)'
  294. sed 's/^X//' << 'SHAR_EOF' > 'setinternal.s' &&
  295. /*
  296. ** This file is part of the alternative 80386 math library and is
  297. ** covered by the GNU General Public license with my modification
  298. ** as noted in the README file that accompanied this file.
  299. **
  300. ** Copyright 1990 G. Geers
  301. **
  302. */
  303. X
  304. X    .align 4
  305. X    .globl setinternal
  306. X
  307. setinternal:
  308. X    pushl %ebp
  309. X    movl %esp, %ebp
  310. X    subl $4, %esp
  311. X
  312. X    fnstcw -8(%ebp)
  313. X    movw -8(%ebp), %ax
  314. X    orw $0x007e, -8(%ebp)    /*  All exceptions except IOP masked */
  315. X    fldcw -8(%ebp)
  316. X
  317. X    leave
  318. X    ret
  319. SHAR_EOF
  320. chmod 0644 setinternal.s ||
  321. echo 'restore of setinternal.s failed'
  322. Wc_c="`wc -c < 'setinternal.s'`"
  323. test 449 -eq "$Wc_c" ||
  324.     echo 'setinternal.s: original size 449, current size' "$Wc_c"
  325. fi
  326. # ============= sin.s ==============
  327. if test -f 'sin.s' -a X"$1" != X"-c"; then
  328.     echo 'x - skipping sin.s (File already exists)'
  329. else
  330. echo 'x - extracting sin.s (Text)'
  331. sed 's/^X//' << 'SHAR_EOF' > 'sin.s' &&
  332. /*
  333. ** This file is part of the alternative 80386 math library and is
  334. ** covered by the GNU General Public license with my modification
  335. ** as noted in the README file that accompanied this file.
  336. **
  337. ** Copyright 1990 G. Geers
  338. **
  339. */
  340. X
  341. X    .align 4
  342. X    .globl sin
  343. sin:
  344. X    pushl %ebp
  345. X    movl %esp,%ebp
  346. X
  347. X    fldl 8(%ebp)
  348. X    fsin
  349. X
  350. X    leave
  351. X    ret
  352. SHAR_EOF
  353. chmod 0644 sin.s ||
  354. echo 'restore of sin.s failed'
  355. Wc_c="`wc -c < 'sin.s'`"
  356. test 320 -eq "$Wc_c" ||
  357.     echo 'sin.s: original size 320, current size' "$Wc_c"
  358. fi
  359. # ============= sinh.s ==============
  360. if test -f 'sinh.s' -a X"$1" != X"-c"; then
  361.     echo 'x - skipping sinh.s (File already exists)'
  362. else
  363. echo 'x - extracting sinh.s (Text)'
  364. sed 's/^X//' << 'SHAR_EOF' > 'sinh.s' &&
  365. /*
  366. ** This file is part of the alternative 80386 math library and is
  367. ** covered by the GNU General Public license with my modification
  368. ** as noted in the README file that accompanied this file.
  369. **
  370. ** Copyright 1990 G. Geers
  371. **
  372. */
  373. X
  374. X    .align 4
  375. .LC2:
  376. X    .double 0.500
  377. X
  378. X    .align 4
  379. X    .globl sinh
  380. sinh:
  381. X    pushl %ebp
  382. X    movl %esp,%ebp
  383. X
  384. X    fldl 8(%ebp)
  385. X    fldl2e
  386. X    fmulp
  387. X    fstl %st(1)
  388. X    frndint
  389. X    fstl %st(2)
  390. X    fsubrp
  391. X    f2xm1
  392. X    fld1
  393. X    faddp
  394. X    fscale
  395. X    fst %st(1)
  396. X
  397. X    fld1
  398. X    fdivp
  399. X    fsubrp
  400. X
  401. X    fldl .LC2
  402. X    fmulp
  403. X
  404. X    leave
  405. X    ret
  406. SHAR_EOF
  407. chmod 0644 sinh.s ||
  408. echo 'restore of sinh.s failed'
  409. Wc_c="`wc -c < 'sinh.s'`"
  410. test 487 -eq "$Wc_c" ||
  411.     echo 'sinh.s: original size 487, current size' "$Wc_c"
  412. fi
  413. # ============= sqrt.s ==============
  414. if test -f 'sqrt.s' -a X"$1" != X"-c"; then
  415.     echo 'x - skipping sqrt.s (File already exists)'
  416. else
  417. echo 'x - extracting sqrt.s (Text)'
  418. sed 's/^X//' << 'SHAR_EOF' > 'sqrt.s' &&
  419. /*
  420. ** This file is part of the alternative 80386 math library and is
  421. ** covered by the GNU General Public license with my modification
  422. ** as noted in the README file that accompanied this file.
  423. **
  424. ** Copyright 1990 G. Geers
  425. **
  426. ** sqrt in the prevailing precision
  427. */
  428. X
  429. X    .align 4
  430. X    .globl sqrt
  431. sqrt:
  432. X    pushl %ebp
  433. X    movl %esp,%ebp
  434. X
  435. X    fldl 8(%ebp)
  436. X    fsqrt
  437. X
  438. X    leave
  439. X    ret
  440. SHAR_EOF
  441. chmod 0644 sqrt.s ||
  442. echo 'restore of sqrt.s failed'
  443. Wc_c="`wc -c < 'sqrt.s'`"
  444. test 359 -eq "$Wc_c" ||
  445.     echo 'sqrt.s: original size 359, current size' "$Wc_c"
  446. fi
  447. # ============= sqrtp.s ==============
  448. if test -f 'sqrtp.s' -a X"$1" != X"-c"; then
  449.     echo 'x - skipping sqrtp.s (File already exists)'
  450. else
  451. echo 'x - extracting sqrtp.s (Text)'
  452. sed 's/^X//' << 'SHAR_EOF' > 'sqrtp.s' &&
  453. /*
  454. ** This file is part of the alternative 80386 math library and is
  455. ** covered by the GNU General Public license with my modification
  456. ** as noted in the README file that accompanied this file.
  457. **
  458. ** Copyright 1990 G. Geers
  459. **
  460. ** sqrt in 64 bit precision always
  461. */
  462. X
  463. X    .align 4
  464. X    .globl sqrtp
  465. sqrtp:
  466. X    pushl %ebp
  467. X    movl %esp,%ebp
  468. X    subl $8, %esp
  469. X
  470. X    fnstcw -12(%ebp)        /* store current control word */
  471. X    fnstcw -16(%ebp)           /* store again */
  472. X    andw  $0xf2ff, -12(%ebp)       /* enable 64 bit precision */
  473. X    fldcw -12(%ebp)
  474. X
  475. X    fldl 8(%ebp)
  476. X    fsqrt
  477. X
  478. X    fldcw -16(%ebp)           /* restore original control word */
  479. X
  480. X    leave
  481. X    ret
  482. SHAR_EOF
  483. chmod 0644 sqrtp.s ||
  484. echo 'restore of sqrtp.s failed'
  485. Wc_c="`wc -c < 'sqrtp.s'`"
  486. test 605 -eq "$Wc_c" ||
  487.     echo 'sqrtp.s: original size 605, current size' "$Wc_c"
  488. fi
  489. # ============= tan.s ==============
  490. if test -f 'tan.s' -a X"$1" != X"-c"; then
  491.     echo 'x - skipping tan.s (File already exists)'
  492. else
  493. echo 'x - extracting tan.s (Text)'
  494. sed 's/^X//' << 'SHAR_EOF' > 'tan.s' &&
  495. /*
  496. ** This file is part of the alternative 80386 math library and is
  497. ** covered by the GNU General Public license with my modification
  498. ** as noted in the README file that accompanied this file.
  499. **
  500. ** Copyright 1990 G. Geers
  501. **
  502. */
  503. X
  504. X    .align 4
  505. X    .globl tan
  506. tan:
  507. X    pushl %ebp
  508. X    movl %esp,%ebp
  509. X
  510. X    fldl 8(%ebp)
  511. X    fptan
  512. X    fstp %st(0)
  513. X
  514. X    leave
  515. X    ret
  516. SHAR_EOF
  517. chmod 0644 tan.s ||
  518. echo 'restore of tan.s failed'
  519. Wc_c="`wc -c < 'tan.s'`"
  520. test 334 -eq "$Wc_c" ||
  521.     echo 'tan.s: original size 334, current size' "$Wc_c"
  522. fi
  523. # ============= tanh.s ==============
  524. if test -f 'tanh.s' -a X"$1" != X"-c"; then
  525.     echo 'x - skipping tanh.s (File already exists)'
  526. else
  527. echo 'x - extracting tanh.s (Text)'
  528. sed 's/^X//' << 'SHAR_EOF' > 'tanh.s' &&
  529. /*
  530. ** This file is part of the alternative 80386 math library and is
  531. ** covered by the GNU General Public license with my modification
  532. ** as noted in the README file that accompanied this file.
  533. **
  534. ** Copyright 1990 G. Geers
  535. **
  536. */
  537. X
  538. X    .align 4
  539. X    .globl tanh
  540. tanh:
  541. X    pushl %ebp
  542. X    movl %esp,%ebp
  543. X    subl $8, %esp
  544. X
  545. X    fldl 8(%ebp)
  546. X    fldl2e
  547. X    fmulp
  548. X    fstl %st(1)
  549. X    frndint
  550. X    fstl %st(2)
  551. X    fsubrp
  552. X    f2xm1
  553. X    fld1
  554. X    faddp
  555. X    fscale
  556. X    fstl %st(1)
  557. X    fstl -16(%ebp)
  558. X
  559. X    fld1
  560. X    fdivp
  561. X
  562. X    fsubr
  563. X    faddl -16(%ebp)
  564. X    fdivrp
  565. X
  566. X    leave
  567. X    ret
  568. SHAR_EOF
  569. chmod 0644 tanh.s ||
  570. echo 'restore of tanh.s failed'
  571. Wc_c="`wc -c < 'tanh.s'`"
  572. test 493 -eq "$Wc_c" ||
  573.     echo 'tanh.s: original size 493, current size' "$Wc_c"
  574. fi
  575. exit 0
  576. --
  577. Glenn Geers                       | "So when it's over, we're back to people.
  578. Department of Theoretical Physics |  Just to prove that human touch can have
  579. The University of Sydney          |  no equal."
  580. Sydney NSW 2006 Australia         |  - Basia Trzetrzelewska, 'Prime Time TV'
  581.