home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / sysdeps / i386 / frexp.S < prev    next >
Encoding:
Text File  |  1994-12-01  |  4.3 KB  |  314 lines

  1.     .file "frexp.S"
  2.  
  3. #ifdef __ELF__
  4. #define _frexp    frexp
  5. #define _ldexp    ldexp
  6. #ifdef __i486__
  7. #define ALIGN_TEXT    16,0x90
  8. #else
  9. #define ALIGN_TEXT    4,0x90
  10. #endif
  11. #define ALIGN_DATA    4
  12. #else
  13. #ifdef __i486__
  14. #define ALIGN_TEXT    4,0x90
  15. #else
  16. #define ALIGN_TEXT    2,0x90
  17. #endif
  18. #define ALIGN_DATA    2
  19. #endif
  20.  
  21. #ifdef __ELF__
  22.     .section    .rodata
  23. #else
  24.     .text
  25. #endif
  26.  
  27.     .align ALIGN_TEXT
  28.  
  29. #ifdef __ELF__
  30. .LC0:
  31. #else
  32. LC0:
  33. #endif
  34.     .double    1.7976931348623157e+308
  35.  
  36.     .align ALIGN_TEXT
  37.  
  38. #ifdef __ELF__
  39. .LC1:
  40. #else
  41. LC1:
  42. #endif
  43.     .long    0x0,0x40000000
  44.  
  45.     .text
  46.     .globl _frexp
  47.  
  48.     .align ALIGN_TEXT
  49. _frexp:
  50.     pushl    %ebp
  51.     movl    %esp,%ebp
  52.     subl    $16,%esp
  53.     pushl    %esi
  54.     pushl    %ebx
  55. /* y = x; */
  56.     fldl    8(%ebp)
  57.     movl    16(%ebp),%ebx
  58.     fstl    -8(%ebp)
  59. /* q = (short *)&y + 3; */
  60.     leal    -2(%ebp),%ecx
  61. /* i  = ( *q >> 4) & 0x7ff; */
  62.     movw    -2(%ebp),%ax
  63.     sarw    $4,%ax
  64.     movl    %eax,%edx
  65.     andl    $2047,%edx
  66. /* if( i != 0 )       */
  67. /*    goto ieeedon; */
  68.     jne    L22
  69. /* if( y == 0.0 ) */
  70.     fldz
  71.     fucompp
  72.     fnstsw    %ax
  73.     andb    $68,%ah
  74.     xorb    $64,%ah
  75.     jne    L18
  76. /* *pw2 = 0; */
  77.     movl    $0,(%ebx)
  78. /* return( 0.0 ); */
  79.     fldz
  80.     jmp    L21
  81.     .align    ALIGN_DATA,0x90
  82. /* do { */
  83. L18:
  84. /* y *= 2.0; */
  85.     fldl    -8(%ebp)
  86.     fadd    %st(0),%st
  87.     fstpl    -8(%ebp)
  88. /* i -= 1; */
  89.     decl    %edx
  90. /* k  = ( *q >> 4) & 0x7ff; */
  91.     movw    (%ecx),%ax
  92.     sarw    $4,%ax
  93.     movl    %eax,%esi
  94.     andl    $2047,%esi
  95. /* while( k == 0 ); */
  96.     je    L18
  97. /* i = i + k; */
  98.     addl    %esi,%edx
  99.     jmp    L16
  100.     .align    ALIGN_DATA,0x90
  101. /* ieeedon: */
  102. L22:
  103.     fstp    %st(0)
  104. L16:
  105. /* i -= 0x3fe; */
  106.     addl    $-1022,%edx
  107. /* *pw2 = i; */
  108.     movl    %edx,(%ebx)
  109. /* *q &= 0x800f; */
  110.     andw    $32783,(%ecx)
  111. /* *q |= 0x3fe0; */
  112.     orw    $16352,(%ecx)
  113. /* return( y ); */
  114.     fldl    -8(%ebp)
  115. L21:
  116.     leal    -24(%ebp),%esp
  117.     popl    %ebx
  118.     popl    %esi
  119.     leave
  120.     ret
  121.  
  122.     .globl    _ldexp
  123.     .align ALIGN_TEXT
  124. _ldexp:
  125.     pushl    %ebp
  126.     movl    %esp,%ebp
  127.     subl    $20,%esp
  128.     pushl    %esi
  129.     pushl    %ebx
  130. /* power of 2 */
  131.     movl    16(%ebp),%esi
  132. /* y = x */
  133.     movl    8(%ebp),%eax
  134.     movl    12(%ebp),%edx
  135.     movl    %eax,-8(%ebp)
  136.     movl    %edx,-4(%ebp)
  137. /* q = (short *)&y + 3; */
  138.     leal    -2(%ebp),%ecx
  139. /* while( (e = (*q & 0x7ff0) >> 4) == 0 ) { */
  140.     movw    -2(%ebp),%dx
  141.     andw    $32752,%dx
  142.     sarw    $4,%dx
  143.     movswl    %dx,%ebx
  144.     testl    %ebx,%ebx
  145.     jne    L25
  146.     fldz
  147. #ifdef __PIC__
  148.     pushl    %ebx
  149.     call    .L2
  150. .L2:
  151.     popl    %ebx
  152.     addl    $_GLOBAL_OFFSET_TABLE_+[.-.L2],%ebx
  153.     fldl    .LC1@GOTOFF(%ebx)
  154.     popl    %ebx
  155. #else
  156. #ifdef __ELF__
  157.     fldl    .LC1
  158. #else
  159.     fldl    LC1
  160. #endif
  161. #endif
  162.     .align    ALIGN_DATA,0x90
  163. L31:
  164. /* if( y == 0.0 )  return( 0.0 ); */
  165.     fldl    -8(%ebp)
  166.     fucom    %st(2)
  167.     fnstsw    %ax
  168.     andb    $69,%ah
  169.     cmpb    $64,%ah
  170.     je    L45
  171. /* if( pw2 > 0 ) { */
  172.     testl    %esi,%esi
  173.     jle    L46
  174. /* y *= 2.0; */
  175.     fadd    %st(0),%st
  176.     fstpl    -8(%ebp)
  177. /* pw2 -= 1; */
  178.     decl    %esi
  179.     jmp    L27
  180.     .align    ALIGN_DATA,0x90
  181. L46:
  182.     fstp    %st(0)
  183. L27:
  184. /* if( pw2 < 0 ) { */
  185.     testl    %esi,%esi
  186.     jge    L28
  187. /* if( pw2 < -53 )  return(0.0); */
  188.     cmpl    $-53,%esi
  189.     jl    L47
  190. /* y /= 2.0; */
  191.     fld    %st(0)
  192.     fdivrl    -8(%ebp)
  193.     fstpl    -8(%ebp)
  194. /* pw2 += 1; */
  195.     incl    %esi
  196. L28:
  197. /* if( pw2 == 0 ) return(y); */
  198.     testl    %esi,%esi
  199.     je    L48
  200. /* } while exponent is zero */
  201.     movw    (%ecx),%ax
  202.     andw    $32752,%ax
  203.     sarw    $4,%ax
  204.     movswl    %ax,%ebx
  205.     testl    %ebx,%ebx
  206.     je    L31
  207.     fstp    %st(0)
  208.     fstp    %st(0)
  209. L25:
  210. /* e += pw2; */
  211.     addl    %esi,%ebx
  212. /* if( e > MEXP )  return( MAXNUM ); */
  213.     cmpl    $2047,%ebx
  214.     jle    L32
  215. #ifdef __PIC__
  216.     pushl    %ebx
  217.     call    .L3
  218. .L3:
  219.     popl    %ebx
  220.     addl    $_GLOBAL_OFFSET_TABLE_+[.-.L3],%ebx
  221.     fldl    .LC0@GOTOFF(%ebx)
  222.     popl    %ebx
  223. #else
  224. #ifdef __ELF__
  225.     fldl    .LC0
  226. #else
  227.     fldl    LC0
  228. #endif
  229. #endif
  230.     jmp    L39
  231.     .align    ALIGN_DATA,0x90
  232. L32:
  233. /* if( e < 1 ) */
  234.     testl    %ebx,%ebx
  235.     jg    L33
  236. /* if( e < -53 ) return(0.0); */
  237.     cmpl    $-53,%ebx
  238.     jge    L34
  239.     jmp    L44
  240.     .align    ALIGN_DATA,0x90
  241. L45:
  242.     fstp    %st(0)
  243. L47:
  244.     fstp    %st(0)
  245.     fstp    %st(0)
  246. L44:
  247.     fldz
  248.     jmp    L39
  249.     .align    ALIGN_DATA,0x90
  250. L34:
  251. /* *q &= 0x800f; */
  252.     andw    $32783,(%ecx)
  253. /* *q |= 0x10; */
  254.     orb    $16,(%ecx)
  255. /* while( e < 1 ) */
  256.     testl    %ebx,%ebx
  257.     jg    L43
  258. #ifdef __PIC__
  259.     pushl    %ebx
  260.     call    .L4
  261. .L4:
  262.     popl    %ebx
  263.     addl    $_GLOBAL_OFFSET_TABLE_+[.-.L4],%ebx
  264.     fldl    .LC1@GOTOFF(%ebx)
  265.     popl    %ebx
  266. #else
  267. #ifdef __ELF__
  268.     fldl    .LC1
  269. #else
  270.     fldl    LC1
  271. #endif
  272. #endif
  273.     .align    ALIGN_DATA,0x90
  274. L37:
  275. /* y /= 2.0; */
  276.     fld    %st(0)
  277.     fdivrl    -8(%ebp)
  278.     fstpl    -8(%ebp)
  279. /* e += 1; */
  280.     incl    %ebx
  281.     testl    %ebx,%ebx
  282.     jle    L37
  283. /* return(y); */
  284.     jmp    L49
  285.     .align    ALIGN_DATA,0x90
  286. L33:
  287. /* *q &= 0x800f; */
  288.     andw    $32783,(%ecx)
  289. /* *q |= (e & 0x7ff) << 4; */
  290.     movl    %ebx,%eax
  291.     andb    $7,%ah
  292.     salw    $4,%ax
  293.     orw    %ax,(%ecx)
  294.     jmp    L43
  295.     .align    ALIGN_DATA,0x90
  296. L48:
  297.     fstp    %st(0)
  298. L49:
  299.     fstp    %st(0)
  300. L43:
  301. /* return(y); */
  302.     fldl    -8(%ebp)
  303. L39:
  304.     leal    -28(%ebp),%esp
  305.     popl    %ebx
  306.     popl    %esi
  307.     leave
  308.     ret
  309.  
  310. #ifdef __ELF__
  311.     .type    frexp,@function
  312.     .type    ldexp,@function
  313. #endif
  314.