linux/arch/m68k/ifpsp060/src/fplsp.S
<<
>>
Prefs
   1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
   3M68000 Hi-Performance Microprocessor Division
   4M68060 Software Package
   5Production Release P1.00 -- October 10, 1994
   6
   7M68060 Software Package Copyright © 1993, 1994 Motorola Inc.  All rights reserved.
   8
   9THE SOFTWARE is provided on an "AS IS" basis and without warranty.
  10To the maximum extent permitted by applicable law,
  11MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
  12INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  13and any warranty against infringement with regard to the SOFTWARE
  14(INCLUDING ANY MODIFIED VERSIONS THEREOF) and any accompanying written materials.
  15
  16To the maximum extent permitted by applicable law,
  17IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
  18(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
  19BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
  20ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
  21Motorola assumes no responsibility for the maintenance and support of the SOFTWARE.
  22
  23You are hereby granted a copyright license to use, modify, and distribute the SOFTWARE
  24so long as this entire notice is retained without alteration in any modified and/or
  25redistributed versions, and that such modified versions are clearly identified as such.
  26No licenses are granted by implication, estoppel or otherwise under any patents
  27or trademarks of Motorola, Inc.
  28~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29#
  30# lfptop.s:
  31#       This file is appended to the top of the 060ILSP package
  32# and contains the entry points into the package. The user, in
  33# effect, branches to one of the branch table entries located here.
  34#
  35
  36        bra.l   _facoss_
  37        short   0x0000
  38        bra.l   _facosd_
  39        short   0x0000
  40        bra.l   _facosx_
  41        short   0x0000
  42
  43        bra.l   _fasins_
  44        short   0x0000
  45        bra.l   _fasind_
  46        short   0x0000
  47        bra.l   _fasinx_
  48        short   0x0000
  49
  50        bra.l   _fatans_
  51        short   0x0000
  52        bra.l   _fatand_
  53        short   0x0000
  54        bra.l   _fatanx_
  55        short   0x0000
  56
  57        bra.l   _fatanhs_
  58        short   0x0000
  59        bra.l   _fatanhd_
  60        short   0x0000
  61        bra.l   _fatanhx_
  62        short   0x0000
  63
  64        bra.l   _fcoss_
  65        short   0x0000
  66        bra.l   _fcosd_
  67        short   0x0000
  68        bra.l   _fcosx_
  69        short   0x0000
  70
  71        bra.l   _fcoshs_
  72        short   0x0000
  73        bra.l   _fcoshd_
  74        short   0x0000
  75        bra.l   _fcoshx_
  76        short   0x0000
  77
  78        bra.l   _fetoxs_
  79        short   0x0000
  80        bra.l   _fetoxd_
  81        short   0x0000
  82        bra.l   _fetoxx_
  83        short   0x0000
  84
  85        bra.l   _fetoxm1s_
  86        short   0x0000
  87        bra.l   _fetoxm1d_
  88        short   0x0000
  89        bra.l   _fetoxm1x_
  90        short   0x0000
  91
  92        bra.l   _fgetexps_
  93        short   0x0000
  94        bra.l   _fgetexpd_
  95        short   0x0000
  96        bra.l   _fgetexpx_
  97        short   0x0000
  98
  99        bra.l   _fgetmans_
 100        short   0x0000
 101        bra.l   _fgetmand_
 102        short   0x0000
 103        bra.l   _fgetmanx_
 104        short   0x0000
 105
 106        bra.l   _flog10s_
 107        short   0x0000
 108        bra.l   _flog10d_
 109        short   0x0000
 110        bra.l   _flog10x_
 111        short   0x0000
 112
 113        bra.l   _flog2s_
 114        short   0x0000
 115        bra.l   _flog2d_
 116        short   0x0000
 117        bra.l   _flog2x_
 118        short   0x0000
 119
 120        bra.l   _flogns_
 121        short   0x0000
 122        bra.l   _flognd_
 123        short   0x0000
 124        bra.l   _flognx_
 125        short   0x0000
 126
 127        bra.l   _flognp1s_
 128        short   0x0000
 129        bra.l   _flognp1d_
 130        short   0x0000
 131        bra.l   _flognp1x_
 132        short   0x0000
 133
 134        bra.l   _fmods_
 135        short   0x0000
 136        bra.l   _fmodd_
 137        short   0x0000
 138        bra.l   _fmodx_
 139        short   0x0000
 140
 141        bra.l   _frems_
 142        short   0x0000
 143        bra.l   _fremd_
 144        short   0x0000
 145        bra.l   _fremx_
 146        short   0x0000
 147
 148        bra.l   _fscales_
 149        short   0x0000
 150        bra.l   _fscaled_
 151        short   0x0000
 152        bra.l   _fscalex_
 153        short   0x0000
 154
 155        bra.l   _fsins_
 156        short   0x0000
 157        bra.l   _fsind_
 158        short   0x0000
 159        bra.l   _fsinx_
 160        short   0x0000
 161
 162        bra.l   _fsincoss_
 163        short   0x0000
 164        bra.l   _fsincosd_
 165        short   0x0000
 166        bra.l   _fsincosx_
 167        short   0x0000
 168
 169        bra.l   _fsinhs_
 170        short   0x0000
 171        bra.l   _fsinhd_
 172        short   0x0000
 173        bra.l   _fsinhx_
 174        short   0x0000
 175
 176        bra.l   _ftans_
 177        short   0x0000
 178        bra.l   _ftand_
 179        short   0x0000
 180        bra.l   _ftanx_
 181        short   0x0000
 182
 183        bra.l   _ftanhs_
 184        short   0x0000
 185        bra.l   _ftanhd_
 186        short   0x0000
 187        bra.l   _ftanhx_
 188        short   0x0000
 189
 190        bra.l   _ftentoxs_
 191        short   0x0000
 192        bra.l   _ftentoxd_
 193        short   0x0000
 194        bra.l   _ftentoxx_
 195        short   0x0000
 196
 197        bra.l   _ftwotoxs_
 198        short   0x0000
 199        bra.l   _ftwotoxd_
 200        short   0x0000
 201        bra.l   _ftwotoxx_
 202        short   0x0000
 203
 204        bra.l   _fabss_
 205        short   0x0000
 206        bra.l   _fabsd_
 207        short   0x0000
 208        bra.l   _fabsx_
 209        short   0x0000
 210
 211        bra.l   _fadds_
 212        short   0x0000
 213        bra.l   _faddd_
 214        short   0x0000
 215        bra.l   _faddx_
 216        short   0x0000
 217
 218        bra.l   _fdivs_
 219        short   0x0000
 220        bra.l   _fdivd_
 221        short   0x0000
 222        bra.l   _fdivx_
 223        short   0x0000
 224
 225        bra.l   _fints_
 226        short   0x0000
 227        bra.l   _fintd_
 228        short   0x0000
 229        bra.l   _fintx_
 230        short   0x0000
 231
 232        bra.l   _fintrzs_
 233        short   0x0000
 234        bra.l   _fintrzd_
 235        short   0x0000
 236        bra.l   _fintrzx_
 237        short   0x0000
 238
 239        bra.l   _fmuls_
 240        short   0x0000
 241        bra.l   _fmuld_
 242        short   0x0000
 243        bra.l   _fmulx_
 244        short   0x0000
 245
 246        bra.l   _fnegs_
 247        short   0x0000
 248        bra.l   _fnegd_
 249        short   0x0000
 250        bra.l   _fnegx_
 251        short   0x0000
 252
 253        bra.l   _fsqrts_
 254        short   0x0000
 255        bra.l   _fsqrtd_
 256        short   0x0000
 257        bra.l   _fsqrtx_
 258        short   0x0000
 259
 260        bra.l   _fsubs_
 261        short   0x0000
 262        bra.l   _fsubd_
 263        short   0x0000
 264        bra.l   _fsubx_
 265        short   0x0000
 266
 267# leave room for future possible additions
 268        align   0x400
 269
 270#
 271# This file contains a set of define statements for constants
 272# in order to promote readability within the corecode itself.
 273#
 274
 275set LOCAL_SIZE,         192                     # stack frame size(bytes)
 276set LV,                 -LOCAL_SIZE             # stack offset
 277
 278set EXC_SR,             0x4                     # stack status register
 279set EXC_PC,             0x6                     # stack pc
 280set EXC_VOFF,           0xa                     # stacked vector offset
 281set EXC_EA,             0xc                     # stacked <ea>
 282
 283set EXC_FP,             0x0                     # frame pointer
 284
 285set EXC_AREGS,          -68                     # offset of all address regs
 286set EXC_DREGS,          -100                    # offset of all data regs
 287set EXC_FPREGS,         -36                     # offset of all fp regs
 288
 289set EXC_A7,             EXC_AREGS+(7*4)         # offset of saved a7
 290set OLD_A7,             EXC_AREGS+(6*4)         # extra copy of saved a7
 291set EXC_A6,             EXC_AREGS+(6*4)         # offset of saved a6
 292set EXC_A5,             EXC_AREGS+(5*4)
 293set EXC_A4,             EXC_AREGS+(4*4)
 294set EXC_A3,             EXC_AREGS+(3*4)
 295set EXC_A2,             EXC_AREGS+(2*4)
 296set EXC_A1,             EXC_AREGS+(1*4)
 297set EXC_A0,             EXC_AREGS+(0*4)
 298set EXC_D7,             EXC_DREGS+(7*4)
 299set EXC_D6,             EXC_DREGS+(6*4)
 300set EXC_D5,             EXC_DREGS+(5*4)
 301set EXC_D4,             EXC_DREGS+(4*4)
 302set EXC_D3,             EXC_DREGS+(3*4)
 303set EXC_D2,             EXC_DREGS+(2*4)
 304set EXC_D1,             EXC_DREGS+(1*4)
 305set EXC_D0,             EXC_DREGS+(0*4)
 306
 307set EXC_FP0,            EXC_FPREGS+(0*12)       # offset of saved fp0
 308set EXC_FP1,            EXC_FPREGS+(1*12)       # offset of saved fp1
 309set EXC_FP2,            EXC_FPREGS+(2*12)       # offset of saved fp2 (not used)
 310
 311set FP_SCR1,            LV+80                   # fp scratch 1
 312set FP_SCR1_EX,         FP_SCR1+0
 313set FP_SCR1_SGN,        FP_SCR1+2
 314set FP_SCR1_HI,         FP_SCR1+4
 315set FP_SCR1_LO,         FP_SCR1+8
 316
 317set FP_SCR0,            LV+68                   # fp scratch 0
 318set FP_SCR0_EX,         FP_SCR0+0
 319set FP_SCR0_SGN,        FP_SCR0+2
 320set FP_SCR0_HI,         FP_SCR0+4
 321set FP_SCR0_LO,         FP_SCR0+8
 322
 323set FP_DST,             LV+56                   # fp destination operand
 324set FP_DST_EX,          FP_DST+0
 325set FP_DST_SGN,         FP_DST+2
 326set FP_DST_HI,          FP_DST+4
 327set FP_DST_LO,          FP_DST+8
 328
 329set FP_SRC,             LV+44                   # fp source operand
 330set FP_SRC_EX,          FP_SRC+0
 331set FP_SRC_SGN,         FP_SRC+2
 332set FP_SRC_HI,          FP_SRC+4
 333set FP_SRC_LO,          FP_SRC+8
 334
 335set USER_FPIAR,         LV+40                   # FP instr address register
 336
 337set USER_FPSR,          LV+36                   # FP status register
 338set FPSR_CC,            USER_FPSR+0             # FPSR condition codes
 339set FPSR_QBYTE,         USER_FPSR+1             # FPSR qoutient byte
 340set FPSR_EXCEPT,        USER_FPSR+2             # FPSR exception status byte
 341set FPSR_AEXCEPT,       USER_FPSR+3             # FPSR accrued exception byte
 342
 343set USER_FPCR,          LV+32                   # FP control register
 344set FPCR_ENABLE,        USER_FPCR+2             # FPCR exception enable
 345set FPCR_MODE,          USER_FPCR+3             # FPCR rounding mode control
 346
 347set L_SCR3,             LV+28                   # integer scratch 3
 348set L_SCR2,             LV+24                   # integer scratch 2
 349set L_SCR1,             LV+20                   # integer scratch 1
 350
 351set STORE_FLG,          LV+19                   # flag: operand store (ie. not fcmp/ftst)
 352
 353set EXC_TEMP2,          LV+24                   # temporary space
 354set EXC_TEMP,           LV+16                   # temporary space
 355
 356set DTAG,               LV+15                   # destination operand type
 357set STAG,               LV+14                   # source operand type
 358
 359set SPCOND_FLG,         LV+10                   # flag: special case (see below)
 360
 361set EXC_CC,             LV+8                    # saved condition codes
 362set EXC_EXTWPTR,        LV+4                    # saved current PC (active)
 363set EXC_EXTWORD,        LV+2                    # saved extension word
 364set EXC_CMDREG,         LV+2                    # saved extension word
 365set EXC_OPWORD,         LV+0                    # saved operation word
 366
 367################################
 368
 369# Helpful macros
 370
 371set FTEMP,              0                       # offsets within an
 372set FTEMP_EX,           0                       # extended precision
 373set FTEMP_SGN,          2                       # value saved in memory.
 374set FTEMP_HI,           4
 375set FTEMP_LO,           8
 376set FTEMP_GRS,          12
 377
 378set LOCAL,              0                       # offsets within an
 379set LOCAL_EX,           0                       # extended precision
 380set LOCAL_SGN,          2                       # value saved in memory.
 381set LOCAL_HI,           4
 382set LOCAL_LO,           8
 383set LOCAL_GRS,          12
 384
 385set DST,                0                       # offsets within an
 386set DST_EX,             0                       # extended precision
 387set DST_HI,             4                       # value saved in memory.
 388set DST_LO,             8
 389
 390set SRC,                0                       # offsets within an
 391set SRC_EX,             0                       # extended precision
 392set SRC_HI,             4                       # value saved in memory.
 393set SRC_LO,             8
 394
 395set SGL_LO,             0x3f81                  # min sgl prec exponent
 396set SGL_HI,             0x407e                  # max sgl prec exponent
 397set DBL_LO,             0x3c01                  # min dbl prec exponent
 398set DBL_HI,             0x43fe                  # max dbl prec exponent
 399set EXT_LO,             0x0                     # min ext prec exponent
 400set EXT_HI,             0x7ffe                  # max ext prec exponent
 401
 402set EXT_BIAS,           0x3fff                  # extended precision bias
 403set SGL_BIAS,           0x007f                  # single precision bias
 404set DBL_BIAS,           0x03ff                  # double precision bias
 405
 406set NORM,               0x00                    # operand type for STAG/DTAG
 407set ZERO,               0x01                    # operand type for STAG/DTAG
 408set INF,                0x02                    # operand type for STAG/DTAG
 409set QNAN,               0x03                    # operand type for STAG/DTAG
 410set DENORM,             0x04                    # operand type for STAG/DTAG
 411set SNAN,               0x05                    # operand type for STAG/DTAG
 412set UNNORM,             0x06                    # operand type for STAG/DTAG
 413
 414##################
 415# FPSR/FPCR bits #
 416##################
 417set neg_bit,            0x3                     # negative result
 418set z_bit,              0x2                     # zero result
 419set inf_bit,            0x1                     # infinite result
 420set nan_bit,            0x0                     # NAN result
 421
 422set q_sn_bit,           0x7                     # sign bit of quotient byte
 423
 424set bsun_bit,           7                       # branch on unordered
 425set snan_bit,           6                       # signalling NAN
 426set operr_bit,          5                       # operand error
 427set ovfl_bit,           4                       # overflow
 428set unfl_bit,           3                       # underflow
 429set dz_bit,             2                       # divide by zero
 430set inex2_bit,          1                       # inexact result 2
 431set inex1_bit,          0                       # inexact result 1
 432
 433set aiop_bit,           7                       # accrued inexact operation bit
 434set aovfl_bit,          6                       # accrued overflow bit
 435set aunfl_bit,          5                       # accrued underflow bit
 436set adz_bit,            4                       # accrued dz bit
 437set ainex_bit,          3                       # accrued inexact bit
 438
 439#############################
 440# FPSR individual bit masks #
 441#############################
 442set neg_mask,           0x08000000              # negative bit mask (lw)
 443set inf_mask,           0x02000000              # infinity bit mask (lw)
 444set z_mask,             0x04000000              # zero bit mask (lw)
 445set nan_mask,           0x01000000              # nan bit mask (lw)
 446
 447set neg_bmask,          0x08                    # negative bit mask (byte)
 448set inf_bmask,          0x02                    # infinity bit mask (byte)
 449set z_bmask,            0x04                    # zero bit mask (byte)
 450set nan_bmask,          0x01                    # nan bit mask (byte)
 451
 452set bsun_mask,          0x00008000              # bsun exception mask
 453set snan_mask,          0x00004000              # snan exception mask
 454set operr_mask,         0x00002000              # operr exception mask
 455set ovfl_mask,          0x00001000              # overflow exception mask
 456set unfl_mask,          0x00000800              # underflow exception mask
 457set dz_mask,            0x00000400              # dz exception mask
 458set inex2_mask,         0x00000200              # inex2 exception mask
 459set inex1_mask,         0x00000100              # inex1 exception mask
 460
 461set aiop_mask,          0x00000080              # accrued illegal operation
 462set aovfl_mask,         0x00000040              # accrued overflow
 463set aunfl_mask,         0x00000020              # accrued underflow
 464set adz_mask,           0x00000010              # accrued divide by zero
 465set ainex_mask,         0x00000008              # accrued inexact
 466
 467######################################
 468# FPSR combinations used in the FPSP #
 469######################################
 470set dzinf_mask,         inf_mask+dz_mask+adz_mask
 471set opnan_mask,         nan_mask+operr_mask+aiop_mask
 472set nzi_mask,           0x01ffffff              #clears N, Z, and I
 473set unfinx_mask,        unfl_mask+inex2_mask+aunfl_mask+ainex_mask
 474set unf2inx_mask,       unfl_mask+inex2_mask+ainex_mask
 475set ovfinx_mask,        ovfl_mask+inex2_mask+aovfl_mask+ainex_mask
 476set inx1a_mask,         inex1_mask+ainex_mask
 477set inx2a_mask,         inex2_mask+ainex_mask
 478set snaniop_mask,       nan_mask+snan_mask+aiop_mask
 479set snaniop2_mask,      snan_mask+aiop_mask
 480set naniop_mask,        nan_mask+aiop_mask
 481set neginf_mask,        neg_mask+inf_mask
 482set infaiop_mask,       inf_mask+aiop_mask
 483set negz_mask,          neg_mask+z_mask
 484set opaop_mask,         operr_mask+aiop_mask
 485set unfl_inx_mask,      unfl_mask+aunfl_mask+ainex_mask
 486set ovfl_inx_mask,      ovfl_mask+aovfl_mask+ainex_mask
 487
 488#########
 489# misc. #
 490#########
 491set rnd_stky_bit,       29                      # stky bit pos in longword
 492
 493set sign_bit,           0x7                     # sign bit
 494set signan_bit,         0x6                     # signalling nan bit
 495
 496set sgl_thresh,         0x3f81                  # minimum sgl exponent
 497set dbl_thresh,         0x3c01                  # minimum dbl exponent
 498
 499set x_mode,             0x0                     # extended precision
 500set s_mode,             0x4                     # single precision
 501set d_mode,             0x8                     # double precision
 502
 503set rn_mode,            0x0                     # round-to-nearest
 504set rz_mode,            0x1                     # round-to-zero
 505set rm_mode,            0x2                     # round-tp-minus-infinity
 506set rp_mode,            0x3                     # round-to-plus-infinity
 507
 508set mantissalen,        64                      # length of mantissa in bits
 509
 510set BYTE,               1                       # len(byte) == 1 byte
 511set WORD,               2                       # len(word) == 2 bytes
 512set LONG,               4                       # len(longword) == 2 bytes
 513
 514set BSUN_VEC,           0xc0                    # bsun    vector offset
 515set INEX_VEC,           0xc4                    # inexact vector offset
 516set DZ_VEC,             0xc8                    # dz      vector offset
 517set UNFL_VEC,           0xcc                    # unfl    vector offset
 518set OPERR_VEC,          0xd0                    # operr   vector offset
 519set OVFL_VEC,           0xd4                    # ovfl    vector offset
 520set SNAN_VEC,           0xd8                    # snan    vector offset
 521
 522###########################
 523# SPecial CONDition FLaGs #
 524###########################
 525set ftrapcc_flg,        0x01                    # flag bit: ftrapcc exception
 526set fbsun_flg,          0x02                    # flag bit: bsun exception
 527set mia7_flg,           0x04                    # flag bit: (a7)+ <ea>
 528set mda7_flg,           0x08                    # flag bit: -(a7) <ea>
 529set fmovm_flg,          0x40                    # flag bit: fmovm instruction
 530set immed_flg,          0x80                    # flag bit: &<data> <ea>
 531
 532set ftrapcc_bit,        0x0
 533set fbsun_bit,          0x1
 534set mia7_bit,           0x2
 535set mda7_bit,           0x3
 536set immed_bit,          0x7
 537
 538##################################
 539# TRANSCENDENTAL "LAST-OP" FLAGS #
 540##################################
 541set FMUL_OP,            0x0                     # fmul instr performed last
 542set FDIV_OP,            0x1                     # fdiv performed last
 543set FADD_OP,            0x2                     # fadd performed last
 544set FMOV_OP,            0x3                     # fmov performed last
 545
 546#############
 547# CONSTANTS #
 548#############
 549T1:     long            0x40C62D38,0xD3D64634   # 16381 LOG2 LEAD
 550T2:     long            0x3D6F90AE,0xB1E75CC7   # 16381 LOG2 TRAIL
 551
 552PI:     long            0x40000000,0xC90FDAA2,0x2168C235,0x00000000
 553PIBY2:  long            0x3FFF0000,0xC90FDAA2,0x2168C235,0x00000000
 554
 555TWOBYPI:
 556        long            0x3FE45F30,0x6DC9C883
 557
 558#########################################################################
 559# MONADIC TEMPLATE                                                      #
 560#########################################################################
 561        global          _fsins_
 562_fsins_:
 563        link            %a6,&-LOCAL_SIZE
 564
 565        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 566        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 567        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 568
 569        fmov.l          &0x0,%fpcr              # zero FPCR
 570
 571#
 572#       copy, convert, and tag input argument
 573#
 574        fmov.s          0x8(%a6),%fp0           # load sgl input
 575        fmov.x          %fp0,FP_SRC(%a6)
 576        lea             FP_SRC(%a6),%a0
 577        bsr.l           tag                     # fetch operand type
 578        mov.b           %d0,STAG(%a6)
 579        mov.b           %d0,%d1
 580
 581        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 582
 583        clr.l           %d0
 584        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 585
 586        tst.b           %d1
 587        bne.b           _L0_2s
 588        bsr.l           ssin                    # operand is a NORM
 589        bra.b           _L0_6s
 590_L0_2s:
 591        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 592        bne.b           _L0_3s                  # no
 593        bsr.l           src_zero                        # yes
 594        bra.b           _L0_6s
 595_L0_3s:
 596        cmpi.b          %d1,&INF                # is operand an INF?
 597        bne.b           _L0_4s                  # no
 598        bsr.l           t_operr                 # yes
 599        bra.b           _L0_6s
 600_L0_4s:
 601        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 602        bne.b           _L0_5s                  # no
 603        bsr.l           src_qnan                        # yes
 604        bra.b           _L0_6s
 605_L0_5s:
 606        bsr.l           ssind                   # operand is a DENORM
 607_L0_6s:
 608
 609#
 610#       Result is now in FP0
 611#
 612        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 613        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 614        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 615        unlk            %a6
 616        rts
 617
 618        global          _fsind_
 619_fsind_:
 620        link            %a6,&-LOCAL_SIZE
 621
 622        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 623        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 624        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 625
 626        fmov.l          &0x0,%fpcr              # zero FPCR
 627
 628#
 629#       copy, convert, and tag input argument
 630#
 631        fmov.d          0x8(%a6),%fp0           # load dbl input
 632        fmov.x          %fp0,FP_SRC(%a6)
 633        lea             FP_SRC(%a6),%a0
 634        bsr.l           tag                     # fetch operand type
 635        mov.b           %d0,STAG(%a6)
 636        mov.b           %d0,%d1
 637
 638        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 639
 640        clr.l           %d0
 641        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 642
 643        mov.b           %d1,STAG(%a6)
 644        tst.b           %d1
 645        bne.b           _L0_2d
 646        bsr.l           ssin                    # operand is a NORM
 647        bra.b           _L0_6d
 648_L0_2d:
 649        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 650        bne.b           _L0_3d                  # no
 651        bsr.l           src_zero                        # yes
 652        bra.b           _L0_6d
 653_L0_3d:
 654        cmpi.b          %d1,&INF                # is operand an INF?
 655        bne.b           _L0_4d                  # no
 656        bsr.l           t_operr                 # yes
 657        bra.b           _L0_6d
 658_L0_4d:
 659        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 660        bne.b           _L0_5d                  # no
 661        bsr.l           src_qnan                        # yes
 662        bra.b           _L0_6d
 663_L0_5d:
 664        bsr.l           ssind                   # operand is a DENORM
 665_L0_6d:
 666
 667#
 668#       Result is now in FP0
 669#
 670        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 671        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 672        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 673        unlk            %a6
 674        rts
 675
 676        global          _fsinx_
 677_fsinx_:
 678        link            %a6,&-LOCAL_SIZE
 679
 680        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 681        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 682        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 683
 684        fmov.l          &0x0,%fpcr              # zero FPCR
 685
 686#
 687#       copy, convert, and tag input argument
 688#
 689        lea             FP_SRC(%a6),%a0
 690        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
 691        mov.l           0x8+0x4(%a6),0x4(%a0)
 692        mov.l           0x8+0x8(%a6),0x8(%a0)
 693        bsr.l           tag                     # fetch operand type
 694        mov.b           %d0,STAG(%a6)
 695        mov.b           %d0,%d1
 696
 697        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 698
 699        clr.l           %d0
 700        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 701
 702        tst.b           %d1
 703        bne.b           _L0_2x
 704        bsr.l           ssin                    # operand is a NORM
 705        bra.b           _L0_6x
 706_L0_2x:
 707        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 708        bne.b           _L0_3x                  # no
 709        bsr.l           src_zero                        # yes
 710        bra.b           _L0_6x
 711_L0_3x:
 712        cmpi.b          %d1,&INF                # is operand an INF?
 713        bne.b           _L0_4x                  # no
 714        bsr.l           t_operr                 # yes
 715        bra.b           _L0_6x
 716_L0_4x:
 717        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 718        bne.b           _L0_5x                  # no
 719        bsr.l           src_qnan                        # yes
 720        bra.b           _L0_6x
 721_L0_5x:
 722        bsr.l           ssind                   # operand is a DENORM
 723_L0_6x:
 724
 725#
 726#       Result is now in FP0
 727#
 728        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 729        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 730        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 731        unlk            %a6
 732        rts
 733
 734
 735#########################################################################
 736# MONADIC TEMPLATE                                                      #
 737#########################################################################
 738        global          _fcoss_
 739_fcoss_:
 740        link            %a6,&-LOCAL_SIZE
 741
 742        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 743        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 744        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 745
 746        fmov.l          &0x0,%fpcr              # zero FPCR
 747
 748#
 749#       copy, convert, and tag input argument
 750#
 751        fmov.s          0x8(%a6),%fp0           # load sgl input
 752        fmov.x          %fp0,FP_SRC(%a6)
 753        lea             FP_SRC(%a6),%a0
 754        bsr.l           tag                     # fetch operand type
 755        mov.b           %d0,STAG(%a6)
 756        mov.b           %d0,%d1
 757
 758        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 759
 760        clr.l           %d0
 761        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 762
 763        tst.b           %d1
 764        bne.b           _L1_2s
 765        bsr.l           scos                    # operand is a NORM
 766        bra.b           _L1_6s
 767_L1_2s:
 768        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 769        bne.b           _L1_3s                  # no
 770        bsr.l           ld_pone                 # yes
 771        bra.b           _L1_6s
 772_L1_3s:
 773        cmpi.b          %d1,&INF                # is operand an INF?
 774        bne.b           _L1_4s                  # no
 775        bsr.l           t_operr                 # yes
 776        bra.b           _L1_6s
 777_L1_4s:
 778        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 779        bne.b           _L1_5s                  # no
 780        bsr.l           src_qnan                        # yes
 781        bra.b           _L1_6s
 782_L1_5s:
 783        bsr.l           scosd                   # operand is a DENORM
 784_L1_6s:
 785
 786#
 787#       Result is now in FP0
 788#
 789        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 790        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 791        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 792        unlk            %a6
 793        rts
 794
 795        global          _fcosd_
 796_fcosd_:
 797        link            %a6,&-LOCAL_SIZE
 798
 799        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 800        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 801        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 802
 803        fmov.l          &0x0,%fpcr              # zero FPCR
 804
 805#
 806#       copy, convert, and tag input argument
 807#
 808        fmov.d          0x8(%a6),%fp0           # load dbl input
 809        fmov.x          %fp0,FP_SRC(%a6)
 810        lea             FP_SRC(%a6),%a0
 811        bsr.l           tag                     # fetch operand type
 812        mov.b           %d0,STAG(%a6)
 813        mov.b           %d0,%d1
 814
 815        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 816
 817        clr.l           %d0
 818        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 819
 820        mov.b           %d1,STAG(%a6)
 821        tst.b           %d1
 822        bne.b           _L1_2d
 823        bsr.l           scos                    # operand is a NORM
 824        bra.b           _L1_6d
 825_L1_2d:
 826        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 827        bne.b           _L1_3d                  # no
 828        bsr.l           ld_pone                 # yes
 829        bra.b           _L1_6d
 830_L1_3d:
 831        cmpi.b          %d1,&INF                # is operand an INF?
 832        bne.b           _L1_4d                  # no
 833        bsr.l           t_operr                 # yes
 834        bra.b           _L1_6d
 835_L1_4d:
 836        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 837        bne.b           _L1_5d                  # no
 838        bsr.l           src_qnan                        # yes
 839        bra.b           _L1_6d
 840_L1_5d:
 841        bsr.l           scosd                   # operand is a DENORM
 842_L1_6d:
 843
 844#
 845#       Result is now in FP0
 846#
 847        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 848        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 849        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 850        unlk            %a6
 851        rts
 852
 853        global          _fcosx_
 854_fcosx_:
 855        link            %a6,&-LOCAL_SIZE
 856
 857        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 858        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 859        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 860
 861        fmov.l          &0x0,%fpcr              # zero FPCR
 862
 863#
 864#       copy, convert, and tag input argument
 865#
 866        lea             FP_SRC(%a6),%a0
 867        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
 868        mov.l           0x8+0x4(%a6),0x4(%a0)
 869        mov.l           0x8+0x8(%a6),0x8(%a0)
 870        bsr.l           tag                     # fetch operand type
 871        mov.b           %d0,STAG(%a6)
 872        mov.b           %d0,%d1
 873
 874        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 875
 876        clr.l           %d0
 877        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 878
 879        tst.b           %d1
 880        bne.b           _L1_2x
 881        bsr.l           scos                    # operand is a NORM
 882        bra.b           _L1_6x
 883_L1_2x:
 884        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 885        bne.b           _L1_3x                  # no
 886        bsr.l           ld_pone                 # yes
 887        bra.b           _L1_6x
 888_L1_3x:
 889        cmpi.b          %d1,&INF                # is operand an INF?
 890        bne.b           _L1_4x                  # no
 891        bsr.l           t_operr                 # yes
 892        bra.b           _L1_6x
 893_L1_4x:
 894        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 895        bne.b           _L1_5x                  # no
 896        bsr.l           src_qnan                        # yes
 897        bra.b           _L1_6x
 898_L1_5x:
 899        bsr.l           scosd                   # operand is a DENORM
 900_L1_6x:
 901
 902#
 903#       Result is now in FP0
 904#
 905        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 906        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 907        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 908        unlk            %a6
 909        rts
 910
 911
 912#########################################################################
 913# MONADIC TEMPLATE                                                      #
 914#########################################################################
 915        global          _fsinhs_
 916_fsinhs_:
 917        link            %a6,&-LOCAL_SIZE
 918
 919        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 920        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 921        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 922
 923        fmov.l          &0x0,%fpcr              # zero FPCR
 924
 925#
 926#       copy, convert, and tag input argument
 927#
 928        fmov.s          0x8(%a6),%fp0           # load sgl input
 929        fmov.x          %fp0,FP_SRC(%a6)
 930        lea             FP_SRC(%a6),%a0
 931        bsr.l           tag                     # fetch operand type
 932        mov.b           %d0,STAG(%a6)
 933        mov.b           %d0,%d1
 934
 935        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 936
 937        clr.l           %d0
 938        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 939
 940        tst.b           %d1
 941        bne.b           _L2_2s
 942        bsr.l           ssinh                   # operand is a NORM
 943        bra.b           _L2_6s
 944_L2_2s:
 945        cmpi.b          %d1,&ZERO               # is operand a ZERO?
 946        bne.b           _L2_3s                  # no
 947        bsr.l           src_zero                        # yes
 948        bra.b           _L2_6s
 949_L2_3s:
 950        cmpi.b          %d1,&INF                # is operand an INF?
 951        bne.b           _L2_4s                  # no
 952        bsr.l           src_inf                 # yes
 953        bra.b           _L2_6s
 954_L2_4s:
 955        cmpi.b          %d1,&QNAN               # is operand a QNAN?
 956        bne.b           _L2_5s                  # no
 957        bsr.l           src_qnan                        # yes
 958        bra.b           _L2_6s
 959_L2_5s:
 960        bsr.l           ssinhd                  # operand is a DENORM
 961_L2_6s:
 962
 963#
 964#       Result is now in FP0
 965#
 966        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
 967        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
 968        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
 969        unlk            %a6
 970        rts
 971
 972        global          _fsinhd_
 973_fsinhd_:
 974        link            %a6,&-LOCAL_SIZE
 975
 976        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
 977        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
 978        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
 979
 980        fmov.l          &0x0,%fpcr              # zero FPCR
 981
 982#
 983#       copy, convert, and tag input argument
 984#
 985        fmov.d          0x8(%a6),%fp0           # load dbl input
 986        fmov.x          %fp0,FP_SRC(%a6)
 987        lea             FP_SRC(%a6),%a0
 988        bsr.l           tag                     # fetch operand type
 989        mov.b           %d0,STAG(%a6)
 990        mov.b           %d0,%d1
 991
 992        andi.l          &0x00ff00ff,USER_FPSR(%a6)
 993
 994        clr.l           %d0
 995        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
 996
 997        mov.b           %d1,STAG(%a6)
 998        tst.b           %d1
 999        bne.b           _L2_2d
1000        bsr.l           ssinh                   # operand is a NORM
1001        bra.b           _L2_6d
1002_L2_2d:
1003        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1004        bne.b           _L2_3d                  # no
1005        bsr.l           src_zero                        # yes
1006        bra.b           _L2_6d
1007_L2_3d:
1008        cmpi.b          %d1,&INF                # is operand an INF?
1009        bne.b           _L2_4d                  # no
1010        bsr.l           src_inf                 # yes
1011        bra.b           _L2_6d
1012_L2_4d:
1013        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1014        bne.b           _L2_5d                  # no
1015        bsr.l           src_qnan                        # yes
1016        bra.b           _L2_6d
1017_L2_5d:
1018        bsr.l           ssinhd                  # operand is a DENORM
1019_L2_6d:
1020
1021#
1022#       Result is now in FP0
1023#
1024        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1025        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1026        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1027        unlk            %a6
1028        rts
1029
1030        global          _fsinhx_
1031_fsinhx_:
1032        link            %a6,&-LOCAL_SIZE
1033
1034        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1035        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1036        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1037
1038        fmov.l          &0x0,%fpcr              # zero FPCR
1039
1040#
1041#       copy, convert, and tag input argument
1042#
1043        lea             FP_SRC(%a6),%a0
1044        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
1045        mov.l           0x8+0x4(%a6),0x4(%a0)
1046        mov.l           0x8+0x8(%a6),0x8(%a0)
1047        bsr.l           tag                     # fetch operand type
1048        mov.b           %d0,STAG(%a6)
1049        mov.b           %d0,%d1
1050
1051        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1052
1053        clr.l           %d0
1054        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1055
1056        tst.b           %d1
1057        bne.b           _L2_2x
1058        bsr.l           ssinh                   # operand is a NORM
1059        bra.b           _L2_6x
1060_L2_2x:
1061        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1062        bne.b           _L2_3x                  # no
1063        bsr.l           src_zero                        # yes
1064        bra.b           _L2_6x
1065_L2_3x:
1066        cmpi.b          %d1,&INF                # is operand an INF?
1067        bne.b           _L2_4x                  # no
1068        bsr.l           src_inf                 # yes
1069        bra.b           _L2_6x
1070_L2_4x:
1071        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1072        bne.b           _L2_5x                  # no
1073        bsr.l           src_qnan                        # yes
1074        bra.b           _L2_6x
1075_L2_5x:
1076        bsr.l           ssinhd                  # operand is a DENORM
1077_L2_6x:
1078
1079#
1080#       Result is now in FP0
1081#
1082        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1083        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1084        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1085        unlk            %a6
1086        rts
1087
1088
1089#########################################################################
1090# MONADIC TEMPLATE                                                      #
1091#########################################################################
1092        global          _flognp1s_
1093_flognp1s_:
1094        link            %a6,&-LOCAL_SIZE
1095
1096        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1097        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1098        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1099
1100        fmov.l          &0x0,%fpcr              # zero FPCR
1101
1102#
1103#       copy, convert, and tag input argument
1104#
1105        fmov.s          0x8(%a6),%fp0           # load sgl input
1106        fmov.x          %fp0,FP_SRC(%a6)
1107        lea             FP_SRC(%a6),%a0
1108        bsr.l           tag                     # fetch operand type
1109        mov.b           %d0,STAG(%a6)
1110        mov.b           %d0,%d1
1111
1112        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1113
1114        clr.l           %d0
1115        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1116
1117        tst.b           %d1
1118        bne.b           _L3_2s
1119        bsr.l           slognp1                 # operand is a NORM
1120        bra.b           _L3_6s
1121_L3_2s:
1122        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1123        bne.b           _L3_3s                  # no
1124        bsr.l           src_zero                        # yes
1125        bra.b           _L3_6s
1126_L3_3s:
1127        cmpi.b          %d1,&INF                # is operand an INF?
1128        bne.b           _L3_4s                  # no
1129        bsr.l           sopr_inf                        # yes
1130        bra.b           _L3_6s
1131_L3_4s:
1132        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1133        bne.b           _L3_5s                  # no
1134        bsr.l           src_qnan                        # yes
1135        bra.b           _L3_6s
1136_L3_5s:
1137        bsr.l           slognp1d                        # operand is a DENORM
1138_L3_6s:
1139
1140#
1141#       Result is now in FP0
1142#
1143        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1144        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1145        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1146        unlk            %a6
1147        rts
1148
1149        global          _flognp1d_
1150_flognp1d_:
1151        link            %a6,&-LOCAL_SIZE
1152
1153        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1154        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1155        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1156
1157        fmov.l          &0x0,%fpcr              # zero FPCR
1158
1159#
1160#       copy, convert, and tag input argument
1161#
1162        fmov.d          0x8(%a6),%fp0           # load dbl input
1163        fmov.x          %fp0,FP_SRC(%a6)
1164        lea             FP_SRC(%a6),%a0
1165        bsr.l           tag                     # fetch operand type
1166        mov.b           %d0,STAG(%a6)
1167        mov.b           %d0,%d1
1168
1169        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1170
1171        clr.l           %d0
1172        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1173
1174        mov.b           %d1,STAG(%a6)
1175        tst.b           %d1
1176        bne.b           _L3_2d
1177        bsr.l           slognp1                 # operand is a NORM
1178        bra.b           _L3_6d
1179_L3_2d:
1180        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1181        bne.b           _L3_3d                  # no
1182        bsr.l           src_zero                        # yes
1183        bra.b           _L3_6d
1184_L3_3d:
1185        cmpi.b          %d1,&INF                # is operand an INF?
1186        bne.b           _L3_4d                  # no
1187        bsr.l           sopr_inf                        # yes
1188        bra.b           _L3_6d
1189_L3_4d:
1190        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1191        bne.b           _L3_5d                  # no
1192        bsr.l           src_qnan                        # yes
1193        bra.b           _L3_6d
1194_L3_5d:
1195        bsr.l           slognp1d                        # operand is a DENORM
1196_L3_6d:
1197
1198#
1199#       Result is now in FP0
1200#
1201        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1202        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1203        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1204        unlk            %a6
1205        rts
1206
1207        global          _flognp1x_
1208_flognp1x_:
1209        link            %a6,&-LOCAL_SIZE
1210
1211        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1212        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1213        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1214
1215        fmov.l          &0x0,%fpcr              # zero FPCR
1216
1217#
1218#       copy, convert, and tag input argument
1219#
1220        lea             FP_SRC(%a6),%a0
1221        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
1222        mov.l           0x8+0x4(%a6),0x4(%a0)
1223        mov.l           0x8+0x8(%a6),0x8(%a0)
1224        bsr.l           tag                     # fetch operand type
1225        mov.b           %d0,STAG(%a6)
1226        mov.b           %d0,%d1
1227
1228        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1229
1230        clr.l           %d0
1231        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1232
1233        tst.b           %d1
1234        bne.b           _L3_2x
1235        bsr.l           slognp1                 # operand is a NORM
1236        bra.b           _L3_6x
1237_L3_2x:
1238        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1239        bne.b           _L3_3x                  # no
1240        bsr.l           src_zero                        # yes
1241        bra.b           _L3_6x
1242_L3_3x:
1243        cmpi.b          %d1,&INF                # is operand an INF?
1244        bne.b           _L3_4x                  # no
1245        bsr.l           sopr_inf                        # yes
1246        bra.b           _L3_6x
1247_L3_4x:
1248        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1249        bne.b           _L3_5x                  # no
1250        bsr.l           src_qnan                        # yes
1251        bra.b           _L3_6x
1252_L3_5x:
1253        bsr.l           slognp1d                        # operand is a DENORM
1254_L3_6x:
1255
1256#
1257#       Result is now in FP0
1258#
1259        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1260        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1261        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1262        unlk            %a6
1263        rts
1264
1265
1266#########################################################################
1267# MONADIC TEMPLATE                                                      #
1268#########################################################################
1269        global          _fetoxm1s_
1270_fetoxm1s_:
1271        link            %a6,&-LOCAL_SIZE
1272
1273        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1274        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1275        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1276
1277        fmov.l          &0x0,%fpcr              # zero FPCR
1278
1279#
1280#       copy, convert, and tag input argument
1281#
1282        fmov.s          0x8(%a6),%fp0           # load sgl input
1283        fmov.x          %fp0,FP_SRC(%a6)
1284        lea             FP_SRC(%a6),%a0
1285        bsr.l           tag                     # fetch operand type
1286        mov.b           %d0,STAG(%a6)
1287        mov.b           %d0,%d1
1288
1289        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1290
1291        clr.l           %d0
1292        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1293
1294        tst.b           %d1
1295        bne.b           _L4_2s
1296        bsr.l           setoxm1                 # operand is a NORM
1297        bra.b           _L4_6s
1298_L4_2s:
1299        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1300        bne.b           _L4_3s                  # no
1301        bsr.l           src_zero                        # yes
1302        bra.b           _L4_6s
1303_L4_3s:
1304        cmpi.b          %d1,&INF                # is operand an INF?
1305        bne.b           _L4_4s                  # no
1306        bsr.l           setoxm1i                        # yes
1307        bra.b           _L4_6s
1308_L4_4s:
1309        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1310        bne.b           _L4_5s                  # no
1311        bsr.l           src_qnan                        # yes
1312        bra.b           _L4_6s
1313_L4_5s:
1314        bsr.l           setoxm1d                        # operand is a DENORM
1315_L4_6s:
1316
1317#
1318#       Result is now in FP0
1319#
1320        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1321        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1322        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1323        unlk            %a6
1324        rts
1325
1326        global          _fetoxm1d_
1327_fetoxm1d_:
1328        link            %a6,&-LOCAL_SIZE
1329
1330        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1331        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1332        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1333
1334        fmov.l          &0x0,%fpcr              # zero FPCR
1335
1336#
1337#       copy, convert, and tag input argument
1338#
1339        fmov.d          0x8(%a6),%fp0           # load dbl input
1340        fmov.x          %fp0,FP_SRC(%a6)
1341        lea             FP_SRC(%a6),%a0
1342        bsr.l           tag                     # fetch operand type
1343        mov.b           %d0,STAG(%a6)
1344        mov.b           %d0,%d1
1345
1346        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1347
1348        clr.l           %d0
1349        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1350
1351        mov.b           %d1,STAG(%a6)
1352        tst.b           %d1
1353        bne.b           _L4_2d
1354        bsr.l           setoxm1                 # operand is a NORM
1355        bra.b           _L4_6d
1356_L4_2d:
1357        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1358        bne.b           _L4_3d                  # no
1359        bsr.l           src_zero                        # yes
1360        bra.b           _L4_6d
1361_L4_3d:
1362        cmpi.b          %d1,&INF                # is operand an INF?
1363        bne.b           _L4_4d                  # no
1364        bsr.l           setoxm1i                        # yes
1365        bra.b           _L4_6d
1366_L4_4d:
1367        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1368        bne.b           _L4_5d                  # no
1369        bsr.l           src_qnan                        # yes
1370        bra.b           _L4_6d
1371_L4_5d:
1372        bsr.l           setoxm1d                        # operand is a DENORM
1373_L4_6d:
1374
1375#
1376#       Result is now in FP0
1377#
1378        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1379        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1380        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1381        unlk            %a6
1382        rts
1383
1384        global          _fetoxm1x_
1385_fetoxm1x_:
1386        link            %a6,&-LOCAL_SIZE
1387
1388        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1389        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1390        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1391
1392        fmov.l          &0x0,%fpcr              # zero FPCR
1393
1394#
1395#       copy, convert, and tag input argument
1396#
1397        lea             FP_SRC(%a6),%a0
1398        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
1399        mov.l           0x8+0x4(%a6),0x4(%a0)
1400        mov.l           0x8+0x8(%a6),0x8(%a0)
1401        bsr.l           tag                     # fetch operand type
1402        mov.b           %d0,STAG(%a6)
1403        mov.b           %d0,%d1
1404
1405        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1406
1407        clr.l           %d0
1408        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1409
1410        tst.b           %d1
1411        bne.b           _L4_2x
1412        bsr.l           setoxm1                 # operand is a NORM
1413        bra.b           _L4_6x
1414_L4_2x:
1415        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1416        bne.b           _L4_3x                  # no
1417        bsr.l           src_zero                        # yes
1418        bra.b           _L4_6x
1419_L4_3x:
1420        cmpi.b          %d1,&INF                # is operand an INF?
1421        bne.b           _L4_4x                  # no
1422        bsr.l           setoxm1i                        # yes
1423        bra.b           _L4_6x
1424_L4_4x:
1425        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1426        bne.b           _L4_5x                  # no
1427        bsr.l           src_qnan                        # yes
1428        bra.b           _L4_6x
1429_L4_5x:
1430        bsr.l           setoxm1d                        # operand is a DENORM
1431_L4_6x:
1432
1433#
1434#       Result is now in FP0
1435#
1436        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1437        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1438        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1439        unlk            %a6
1440        rts
1441
1442
1443#########################################################################
1444# MONADIC TEMPLATE                                                      #
1445#########################################################################
1446        global          _ftanhs_
1447_ftanhs_:
1448        link            %a6,&-LOCAL_SIZE
1449
1450        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1451        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1452        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1453
1454        fmov.l          &0x0,%fpcr              # zero FPCR
1455
1456#
1457#       copy, convert, and tag input argument
1458#
1459        fmov.s          0x8(%a6),%fp0           # load sgl input
1460        fmov.x          %fp0,FP_SRC(%a6)
1461        lea             FP_SRC(%a6),%a0
1462        bsr.l           tag                     # fetch operand type
1463        mov.b           %d0,STAG(%a6)
1464        mov.b           %d0,%d1
1465
1466        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1467
1468        clr.l           %d0
1469        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1470
1471        tst.b           %d1
1472        bne.b           _L5_2s
1473        bsr.l           stanh                   # operand is a NORM
1474        bra.b           _L5_6s
1475_L5_2s:
1476        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1477        bne.b           _L5_3s                  # no
1478        bsr.l           src_zero                        # yes
1479        bra.b           _L5_6s
1480_L5_3s:
1481        cmpi.b          %d1,&INF                # is operand an INF?
1482        bne.b           _L5_4s                  # no
1483        bsr.l           src_one                 # yes
1484        bra.b           _L5_6s
1485_L5_4s:
1486        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1487        bne.b           _L5_5s                  # no
1488        bsr.l           src_qnan                        # yes
1489        bra.b           _L5_6s
1490_L5_5s:
1491        bsr.l           stanhd                  # operand is a DENORM
1492_L5_6s:
1493
1494#
1495#       Result is now in FP0
1496#
1497        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1498        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1499        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1500        unlk            %a6
1501        rts
1502
1503        global          _ftanhd_
1504_ftanhd_:
1505        link            %a6,&-LOCAL_SIZE
1506
1507        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1508        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1509        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1510
1511        fmov.l          &0x0,%fpcr              # zero FPCR
1512
1513#
1514#       copy, convert, and tag input argument
1515#
1516        fmov.d          0x8(%a6),%fp0           # load dbl input
1517        fmov.x          %fp0,FP_SRC(%a6)
1518        lea             FP_SRC(%a6),%a0
1519        bsr.l           tag                     # fetch operand type
1520        mov.b           %d0,STAG(%a6)
1521        mov.b           %d0,%d1
1522
1523        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1524
1525        clr.l           %d0
1526        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1527
1528        mov.b           %d1,STAG(%a6)
1529        tst.b           %d1
1530        bne.b           _L5_2d
1531        bsr.l           stanh                   # operand is a NORM
1532        bra.b           _L5_6d
1533_L5_2d:
1534        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1535        bne.b           _L5_3d                  # no
1536        bsr.l           src_zero                        # yes
1537        bra.b           _L5_6d
1538_L5_3d:
1539        cmpi.b          %d1,&INF                # is operand an INF?
1540        bne.b           _L5_4d                  # no
1541        bsr.l           src_one                 # yes
1542        bra.b           _L5_6d
1543_L5_4d:
1544        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1545        bne.b           _L5_5d                  # no
1546        bsr.l           src_qnan                        # yes
1547        bra.b           _L5_6d
1548_L5_5d:
1549        bsr.l           stanhd                  # operand is a DENORM
1550_L5_6d:
1551
1552#
1553#       Result is now in FP0
1554#
1555        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1556        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1557        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1558        unlk            %a6
1559        rts
1560
1561        global          _ftanhx_
1562_ftanhx_:
1563        link            %a6,&-LOCAL_SIZE
1564
1565        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1566        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1567        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1568
1569        fmov.l          &0x0,%fpcr              # zero FPCR
1570
1571#
1572#       copy, convert, and tag input argument
1573#
1574        lea             FP_SRC(%a6),%a0
1575        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
1576        mov.l           0x8+0x4(%a6),0x4(%a0)
1577        mov.l           0x8+0x8(%a6),0x8(%a0)
1578        bsr.l           tag                     # fetch operand type
1579        mov.b           %d0,STAG(%a6)
1580        mov.b           %d0,%d1
1581
1582        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1583
1584        clr.l           %d0
1585        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1586
1587        tst.b           %d1
1588        bne.b           _L5_2x
1589        bsr.l           stanh                   # operand is a NORM
1590        bra.b           _L5_6x
1591_L5_2x:
1592        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1593        bne.b           _L5_3x                  # no
1594        bsr.l           src_zero                        # yes
1595        bra.b           _L5_6x
1596_L5_3x:
1597        cmpi.b          %d1,&INF                # is operand an INF?
1598        bne.b           _L5_4x                  # no
1599        bsr.l           src_one                 # yes
1600        bra.b           _L5_6x
1601_L5_4x:
1602        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1603        bne.b           _L5_5x                  # no
1604        bsr.l           src_qnan                        # yes
1605        bra.b           _L5_6x
1606_L5_5x:
1607        bsr.l           stanhd                  # operand is a DENORM
1608_L5_6x:
1609
1610#
1611#       Result is now in FP0
1612#
1613        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1614        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1615        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1616        unlk            %a6
1617        rts
1618
1619
1620#########################################################################
1621# MONADIC TEMPLATE                                                      #
1622#########################################################################
1623        global          _fatans_
1624_fatans_:
1625        link            %a6,&-LOCAL_SIZE
1626
1627        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1628        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1629        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1630
1631        fmov.l          &0x0,%fpcr              # zero FPCR
1632
1633#
1634#       copy, convert, and tag input argument
1635#
1636        fmov.s          0x8(%a6),%fp0           # load sgl input
1637        fmov.x          %fp0,FP_SRC(%a6)
1638        lea             FP_SRC(%a6),%a0
1639        bsr.l           tag                     # fetch operand type
1640        mov.b           %d0,STAG(%a6)
1641        mov.b           %d0,%d1
1642
1643        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1644
1645        clr.l           %d0
1646        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1647
1648        tst.b           %d1
1649        bne.b           _L6_2s
1650        bsr.l           satan                   # operand is a NORM
1651        bra.b           _L6_6s
1652_L6_2s:
1653        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1654        bne.b           _L6_3s                  # no
1655        bsr.l           src_zero                        # yes
1656        bra.b           _L6_6s
1657_L6_3s:
1658        cmpi.b          %d1,&INF                # is operand an INF?
1659        bne.b           _L6_4s                  # no
1660        bsr.l           spi_2                   # yes
1661        bra.b           _L6_6s
1662_L6_4s:
1663        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1664        bne.b           _L6_5s                  # no
1665        bsr.l           src_qnan                        # yes
1666        bra.b           _L6_6s
1667_L6_5s:
1668        bsr.l           satand                  # operand is a DENORM
1669_L6_6s:
1670
1671#
1672#       Result is now in FP0
1673#
1674        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1675        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1676        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1677        unlk            %a6
1678        rts
1679
1680        global          _fatand_
1681_fatand_:
1682        link            %a6,&-LOCAL_SIZE
1683
1684        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1685        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1686        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1687
1688        fmov.l          &0x0,%fpcr              # zero FPCR
1689
1690#
1691#       copy, convert, and tag input argument
1692#
1693        fmov.d          0x8(%a6),%fp0           # load dbl input
1694        fmov.x          %fp0,FP_SRC(%a6)
1695        lea             FP_SRC(%a6),%a0
1696        bsr.l           tag                     # fetch operand type
1697        mov.b           %d0,STAG(%a6)
1698        mov.b           %d0,%d1
1699
1700        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1701
1702        clr.l           %d0
1703        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1704
1705        mov.b           %d1,STAG(%a6)
1706        tst.b           %d1
1707        bne.b           _L6_2d
1708        bsr.l           satan                   # operand is a NORM
1709        bra.b           _L6_6d
1710_L6_2d:
1711        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1712        bne.b           _L6_3d                  # no
1713        bsr.l           src_zero                        # yes
1714        bra.b           _L6_6d
1715_L6_3d:
1716        cmpi.b          %d1,&INF                # is operand an INF?
1717        bne.b           _L6_4d                  # no
1718        bsr.l           spi_2                   # yes
1719        bra.b           _L6_6d
1720_L6_4d:
1721        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1722        bne.b           _L6_5d                  # no
1723        bsr.l           src_qnan                        # yes
1724        bra.b           _L6_6d
1725_L6_5d:
1726        bsr.l           satand                  # operand is a DENORM
1727_L6_6d:
1728
1729#
1730#       Result is now in FP0
1731#
1732        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1733        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1734        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1735        unlk            %a6
1736        rts
1737
1738        global          _fatanx_
1739_fatanx_:
1740        link            %a6,&-LOCAL_SIZE
1741
1742        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1743        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1744        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1745
1746        fmov.l          &0x0,%fpcr              # zero FPCR
1747
1748#
1749#       copy, convert, and tag input argument
1750#
1751        lea             FP_SRC(%a6),%a0
1752        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
1753        mov.l           0x8+0x4(%a6),0x4(%a0)
1754        mov.l           0x8+0x8(%a6),0x8(%a0)
1755        bsr.l           tag                     # fetch operand type
1756        mov.b           %d0,STAG(%a6)
1757        mov.b           %d0,%d1
1758
1759        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1760
1761        clr.l           %d0
1762        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1763
1764        tst.b           %d1
1765        bne.b           _L6_2x
1766        bsr.l           satan                   # operand is a NORM
1767        bra.b           _L6_6x
1768_L6_2x:
1769        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1770        bne.b           _L6_3x                  # no
1771        bsr.l           src_zero                        # yes
1772        bra.b           _L6_6x
1773_L6_3x:
1774        cmpi.b          %d1,&INF                # is operand an INF?
1775        bne.b           _L6_4x                  # no
1776        bsr.l           spi_2                   # yes
1777        bra.b           _L6_6x
1778_L6_4x:
1779        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1780        bne.b           _L6_5x                  # no
1781        bsr.l           src_qnan                        # yes
1782        bra.b           _L6_6x
1783_L6_5x:
1784        bsr.l           satand                  # operand is a DENORM
1785_L6_6x:
1786
1787#
1788#       Result is now in FP0
1789#
1790        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1791        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1792        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1793        unlk            %a6
1794        rts
1795
1796
1797#########################################################################
1798# MONADIC TEMPLATE                                                      #
1799#########################################################################
1800        global          _fasins_
1801_fasins_:
1802        link            %a6,&-LOCAL_SIZE
1803
1804        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1805        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1806        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1807
1808        fmov.l          &0x0,%fpcr              # zero FPCR
1809
1810#
1811#       copy, convert, and tag input argument
1812#
1813        fmov.s          0x8(%a6),%fp0           # load sgl input
1814        fmov.x          %fp0,FP_SRC(%a6)
1815        lea             FP_SRC(%a6),%a0
1816        bsr.l           tag                     # fetch operand type
1817        mov.b           %d0,STAG(%a6)
1818        mov.b           %d0,%d1
1819
1820        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1821
1822        clr.l           %d0
1823        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1824
1825        tst.b           %d1
1826        bne.b           _L7_2s
1827        bsr.l           sasin                   # operand is a NORM
1828        bra.b           _L7_6s
1829_L7_2s:
1830        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1831        bne.b           _L7_3s                  # no
1832        bsr.l           src_zero                        # yes
1833        bra.b           _L7_6s
1834_L7_3s:
1835        cmpi.b          %d1,&INF                # is operand an INF?
1836        bne.b           _L7_4s                  # no
1837        bsr.l           t_operr                 # yes
1838        bra.b           _L7_6s
1839_L7_4s:
1840        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1841        bne.b           _L7_5s                  # no
1842        bsr.l           src_qnan                        # yes
1843        bra.b           _L7_6s
1844_L7_5s:
1845        bsr.l           sasind                  # operand is a DENORM
1846_L7_6s:
1847
1848#
1849#       Result is now in FP0
1850#
1851        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1852        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1853        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1854        unlk            %a6
1855        rts
1856
1857        global          _fasind_
1858_fasind_:
1859        link            %a6,&-LOCAL_SIZE
1860
1861        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1862        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1863        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1864
1865        fmov.l          &0x0,%fpcr              # zero FPCR
1866
1867#
1868#       copy, convert, and tag input argument
1869#
1870        fmov.d          0x8(%a6),%fp0           # load dbl input
1871        fmov.x          %fp0,FP_SRC(%a6)
1872        lea             FP_SRC(%a6),%a0
1873        bsr.l           tag                     # fetch operand type
1874        mov.b           %d0,STAG(%a6)
1875        mov.b           %d0,%d1
1876
1877        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1878
1879        clr.l           %d0
1880        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1881
1882        mov.b           %d1,STAG(%a6)
1883        tst.b           %d1
1884        bne.b           _L7_2d
1885        bsr.l           sasin                   # operand is a NORM
1886        bra.b           _L7_6d
1887_L7_2d:
1888        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1889        bne.b           _L7_3d                  # no
1890        bsr.l           src_zero                        # yes
1891        bra.b           _L7_6d
1892_L7_3d:
1893        cmpi.b          %d1,&INF                # is operand an INF?
1894        bne.b           _L7_4d                  # no
1895        bsr.l           t_operr                 # yes
1896        bra.b           _L7_6d
1897_L7_4d:
1898        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1899        bne.b           _L7_5d                  # no
1900        bsr.l           src_qnan                        # yes
1901        bra.b           _L7_6d
1902_L7_5d:
1903        bsr.l           sasind                  # operand is a DENORM
1904_L7_6d:
1905
1906#
1907#       Result is now in FP0
1908#
1909        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1910        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1911        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1912        unlk            %a6
1913        rts
1914
1915        global          _fasinx_
1916_fasinx_:
1917        link            %a6,&-LOCAL_SIZE
1918
1919        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1920        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1921        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1922
1923        fmov.l          &0x0,%fpcr              # zero FPCR
1924
1925#
1926#       copy, convert, and tag input argument
1927#
1928        lea             FP_SRC(%a6),%a0
1929        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
1930        mov.l           0x8+0x4(%a6),0x4(%a0)
1931        mov.l           0x8+0x8(%a6),0x8(%a0)
1932        bsr.l           tag                     # fetch operand type
1933        mov.b           %d0,STAG(%a6)
1934        mov.b           %d0,%d1
1935
1936        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1937
1938        clr.l           %d0
1939        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
1940
1941        tst.b           %d1
1942        bne.b           _L7_2x
1943        bsr.l           sasin                   # operand is a NORM
1944        bra.b           _L7_6x
1945_L7_2x:
1946        cmpi.b          %d1,&ZERO               # is operand a ZERO?
1947        bne.b           _L7_3x                  # no
1948        bsr.l           src_zero                        # yes
1949        bra.b           _L7_6x
1950_L7_3x:
1951        cmpi.b          %d1,&INF                # is operand an INF?
1952        bne.b           _L7_4x                  # no
1953        bsr.l           t_operr                 # yes
1954        bra.b           _L7_6x
1955_L7_4x:
1956        cmpi.b          %d1,&QNAN               # is operand a QNAN?
1957        bne.b           _L7_5x                  # no
1958        bsr.l           src_qnan                        # yes
1959        bra.b           _L7_6x
1960_L7_5x:
1961        bsr.l           sasind                  # operand is a DENORM
1962_L7_6x:
1963
1964#
1965#       Result is now in FP0
1966#
1967        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
1968        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
1969        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
1970        unlk            %a6
1971        rts
1972
1973
1974#########################################################################
1975# MONADIC TEMPLATE                                                      #
1976#########################################################################
1977        global          _fatanhs_
1978_fatanhs_:
1979        link            %a6,&-LOCAL_SIZE
1980
1981        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
1982        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
1983        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
1984
1985        fmov.l          &0x0,%fpcr              # zero FPCR
1986
1987#
1988#       copy, convert, and tag input argument
1989#
1990        fmov.s          0x8(%a6),%fp0           # load sgl input
1991        fmov.x          %fp0,FP_SRC(%a6)
1992        lea             FP_SRC(%a6),%a0
1993        bsr.l           tag                     # fetch operand type
1994        mov.b           %d0,STAG(%a6)
1995        mov.b           %d0,%d1
1996
1997        andi.l          &0x00ff00ff,USER_FPSR(%a6)
1998
1999        clr.l           %d0
2000        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2001
2002        tst.b           %d1
2003        bne.b           _L8_2s
2004        bsr.l           satanh                  # operand is a NORM
2005        bra.b           _L8_6s
2006_L8_2s:
2007        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2008        bne.b           _L8_3s                  # no
2009        bsr.l           src_zero                        # yes
2010        bra.b           _L8_6s
2011_L8_3s:
2012        cmpi.b          %d1,&INF                # is operand an INF?
2013        bne.b           _L8_4s                  # no
2014        bsr.l           t_operr                 # yes
2015        bra.b           _L8_6s
2016_L8_4s:
2017        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2018        bne.b           _L8_5s                  # no
2019        bsr.l           src_qnan                        # yes
2020        bra.b           _L8_6s
2021_L8_5s:
2022        bsr.l           satanhd                 # operand is a DENORM
2023_L8_6s:
2024
2025#
2026#       Result is now in FP0
2027#
2028        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2029        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2030        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2031        unlk            %a6
2032        rts
2033
2034        global          _fatanhd_
2035_fatanhd_:
2036        link            %a6,&-LOCAL_SIZE
2037
2038        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2039        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2040        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2041
2042        fmov.l          &0x0,%fpcr              # zero FPCR
2043
2044#
2045#       copy, convert, and tag input argument
2046#
2047        fmov.d          0x8(%a6),%fp0           # load dbl input
2048        fmov.x          %fp0,FP_SRC(%a6)
2049        lea             FP_SRC(%a6),%a0
2050        bsr.l           tag                     # fetch operand type
2051        mov.b           %d0,STAG(%a6)
2052        mov.b           %d0,%d1
2053
2054        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2055
2056        clr.l           %d0
2057        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2058
2059        mov.b           %d1,STAG(%a6)
2060        tst.b           %d1
2061        bne.b           _L8_2d
2062        bsr.l           satanh                  # operand is a NORM
2063        bra.b           _L8_6d
2064_L8_2d:
2065        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2066        bne.b           _L8_3d                  # no
2067        bsr.l           src_zero                        # yes
2068        bra.b           _L8_6d
2069_L8_3d:
2070        cmpi.b          %d1,&INF                # is operand an INF?
2071        bne.b           _L8_4d                  # no
2072        bsr.l           t_operr                 # yes
2073        bra.b           _L8_6d
2074_L8_4d:
2075        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2076        bne.b           _L8_5d                  # no
2077        bsr.l           src_qnan                        # yes
2078        bra.b           _L8_6d
2079_L8_5d:
2080        bsr.l           satanhd                 # operand is a DENORM
2081_L8_6d:
2082
2083#
2084#       Result is now in FP0
2085#
2086        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2087        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2088        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2089        unlk            %a6
2090        rts
2091
2092        global          _fatanhx_
2093_fatanhx_:
2094        link            %a6,&-LOCAL_SIZE
2095
2096        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2097        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2098        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2099
2100        fmov.l          &0x0,%fpcr              # zero FPCR
2101
2102#
2103#       copy, convert, and tag input argument
2104#
2105        lea             FP_SRC(%a6),%a0
2106        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
2107        mov.l           0x8+0x4(%a6),0x4(%a0)
2108        mov.l           0x8+0x8(%a6),0x8(%a0)
2109        bsr.l           tag                     # fetch operand type
2110        mov.b           %d0,STAG(%a6)
2111        mov.b           %d0,%d1
2112
2113        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2114
2115        clr.l           %d0
2116        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2117
2118        tst.b           %d1
2119        bne.b           _L8_2x
2120        bsr.l           satanh                  # operand is a NORM
2121        bra.b           _L8_6x
2122_L8_2x:
2123        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2124        bne.b           _L8_3x                  # no
2125        bsr.l           src_zero                        # yes
2126        bra.b           _L8_6x
2127_L8_3x:
2128        cmpi.b          %d1,&INF                # is operand an INF?
2129        bne.b           _L8_4x                  # no
2130        bsr.l           t_operr                 # yes
2131        bra.b           _L8_6x
2132_L8_4x:
2133        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2134        bne.b           _L8_5x                  # no
2135        bsr.l           src_qnan                        # yes
2136        bra.b           _L8_6x
2137_L8_5x:
2138        bsr.l           satanhd                 # operand is a DENORM
2139_L8_6x:
2140
2141#
2142#       Result is now in FP0
2143#
2144        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2145        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2146        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2147        unlk            %a6
2148        rts
2149
2150
2151#########################################################################
2152# MONADIC TEMPLATE                                                      #
2153#########################################################################
2154        global          _ftans_
2155_ftans_:
2156        link            %a6,&-LOCAL_SIZE
2157
2158        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2159        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2160        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2161
2162        fmov.l          &0x0,%fpcr              # zero FPCR
2163
2164#
2165#       copy, convert, and tag input argument
2166#
2167        fmov.s          0x8(%a6),%fp0           # load sgl input
2168        fmov.x          %fp0,FP_SRC(%a6)
2169        lea             FP_SRC(%a6),%a0
2170        bsr.l           tag                     # fetch operand type
2171        mov.b           %d0,STAG(%a6)
2172        mov.b           %d0,%d1
2173
2174        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2175
2176        clr.l           %d0
2177        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2178
2179        tst.b           %d1
2180        bne.b           _L9_2s
2181        bsr.l           stan                    # operand is a NORM
2182        bra.b           _L9_6s
2183_L9_2s:
2184        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2185        bne.b           _L9_3s                  # no
2186        bsr.l           src_zero                        # yes
2187        bra.b           _L9_6s
2188_L9_3s:
2189        cmpi.b          %d1,&INF                # is operand an INF?
2190        bne.b           _L9_4s                  # no
2191        bsr.l           t_operr                 # yes
2192        bra.b           _L9_6s
2193_L9_4s:
2194        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2195        bne.b           _L9_5s                  # no
2196        bsr.l           src_qnan                        # yes
2197        bra.b           _L9_6s
2198_L9_5s:
2199        bsr.l           stand                   # operand is a DENORM
2200_L9_6s:
2201
2202#
2203#       Result is now in FP0
2204#
2205        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2206        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2207        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2208        unlk            %a6
2209        rts
2210
2211        global          _ftand_
2212_ftand_:
2213        link            %a6,&-LOCAL_SIZE
2214
2215        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2216        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2217        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2218
2219        fmov.l          &0x0,%fpcr              # zero FPCR
2220
2221#
2222#       copy, convert, and tag input argument
2223#
2224        fmov.d          0x8(%a6),%fp0           # load dbl input
2225        fmov.x          %fp0,FP_SRC(%a6)
2226        lea             FP_SRC(%a6),%a0
2227        bsr.l           tag                     # fetch operand type
2228        mov.b           %d0,STAG(%a6)
2229        mov.b           %d0,%d1
2230
2231        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2232
2233        clr.l           %d0
2234        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2235
2236        mov.b           %d1,STAG(%a6)
2237        tst.b           %d1
2238        bne.b           _L9_2d
2239        bsr.l           stan                    # operand is a NORM
2240        bra.b           _L9_6d
2241_L9_2d:
2242        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2243        bne.b           _L9_3d                  # no
2244        bsr.l           src_zero                        # yes
2245        bra.b           _L9_6d
2246_L9_3d:
2247        cmpi.b          %d1,&INF                # is operand an INF?
2248        bne.b           _L9_4d                  # no
2249        bsr.l           t_operr                 # yes
2250        bra.b           _L9_6d
2251_L9_4d:
2252        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2253        bne.b           _L9_5d                  # no
2254        bsr.l           src_qnan                        # yes
2255        bra.b           _L9_6d
2256_L9_5d:
2257        bsr.l           stand                   # operand is a DENORM
2258_L9_6d:
2259
2260#
2261#       Result is now in FP0
2262#
2263        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2264        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2265        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2266        unlk            %a6
2267        rts
2268
2269        global          _ftanx_
2270_ftanx_:
2271        link            %a6,&-LOCAL_SIZE
2272
2273        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2274        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2275        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2276
2277        fmov.l          &0x0,%fpcr              # zero FPCR
2278
2279#
2280#       copy, convert, and tag input argument
2281#
2282        lea             FP_SRC(%a6),%a0
2283        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
2284        mov.l           0x8+0x4(%a6),0x4(%a0)
2285        mov.l           0x8+0x8(%a6),0x8(%a0)
2286        bsr.l           tag                     # fetch operand type
2287        mov.b           %d0,STAG(%a6)
2288        mov.b           %d0,%d1
2289
2290        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2291
2292        clr.l           %d0
2293        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2294
2295        tst.b           %d1
2296        bne.b           _L9_2x
2297        bsr.l           stan                    # operand is a NORM
2298        bra.b           _L9_6x
2299_L9_2x:
2300        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2301        bne.b           _L9_3x                  # no
2302        bsr.l           src_zero                        # yes
2303        bra.b           _L9_6x
2304_L9_3x:
2305        cmpi.b          %d1,&INF                # is operand an INF?
2306        bne.b           _L9_4x                  # no
2307        bsr.l           t_operr                 # yes
2308        bra.b           _L9_6x
2309_L9_4x:
2310        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2311        bne.b           _L9_5x                  # no
2312        bsr.l           src_qnan                        # yes
2313        bra.b           _L9_6x
2314_L9_5x:
2315        bsr.l           stand                   # operand is a DENORM
2316_L9_6x:
2317
2318#
2319#       Result is now in FP0
2320#
2321        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2322        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2323        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2324        unlk            %a6
2325        rts
2326
2327
2328#########################################################################
2329# MONADIC TEMPLATE                                                      #
2330#########################################################################
2331        global          _fetoxs_
2332_fetoxs_:
2333        link            %a6,&-LOCAL_SIZE
2334
2335        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2336        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2337        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2338
2339        fmov.l          &0x0,%fpcr              # zero FPCR
2340
2341#
2342#       copy, convert, and tag input argument
2343#
2344        fmov.s          0x8(%a6),%fp0           # load sgl input
2345        fmov.x          %fp0,FP_SRC(%a6)
2346        lea             FP_SRC(%a6),%a0
2347        bsr.l           tag                     # fetch operand type
2348        mov.b           %d0,STAG(%a6)
2349        mov.b           %d0,%d1
2350
2351        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2352
2353        clr.l           %d0
2354        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2355
2356        tst.b           %d1
2357        bne.b           _L10_2s
2358        bsr.l           setox                   # operand is a NORM
2359        bra.b           _L10_6s
2360_L10_2s:
2361        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2362        bne.b           _L10_3s                 # no
2363        bsr.l           ld_pone                 # yes
2364        bra.b           _L10_6s
2365_L10_3s:
2366        cmpi.b          %d1,&INF                # is operand an INF?
2367        bne.b           _L10_4s                 # no
2368        bsr.l           szr_inf                 # yes
2369        bra.b           _L10_6s
2370_L10_4s:
2371        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2372        bne.b           _L10_5s                 # no
2373        bsr.l           src_qnan                        # yes
2374        bra.b           _L10_6s
2375_L10_5s:
2376        bsr.l           setoxd                  # operand is a DENORM
2377_L10_6s:
2378
2379#
2380#       Result is now in FP0
2381#
2382        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2383        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2384        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2385        unlk            %a6
2386        rts
2387
2388        global          _fetoxd_
2389_fetoxd_:
2390        link            %a6,&-LOCAL_SIZE
2391
2392        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2393        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2394        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2395
2396        fmov.l          &0x0,%fpcr              # zero FPCR
2397
2398#
2399#       copy, convert, and tag input argument
2400#
2401        fmov.d          0x8(%a6),%fp0           # load dbl input
2402        fmov.x          %fp0,FP_SRC(%a6)
2403        lea             FP_SRC(%a6),%a0
2404        bsr.l           tag                     # fetch operand type
2405        mov.b           %d0,STAG(%a6)
2406        mov.b           %d0,%d1
2407
2408        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2409
2410        clr.l           %d0
2411        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2412
2413        mov.b           %d1,STAG(%a6)
2414        tst.b           %d1
2415        bne.b           _L10_2d
2416        bsr.l           setox                   # operand is a NORM
2417        bra.b           _L10_6d
2418_L10_2d:
2419        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2420        bne.b           _L10_3d                 # no
2421        bsr.l           ld_pone                 # yes
2422        bra.b           _L10_6d
2423_L10_3d:
2424        cmpi.b          %d1,&INF                # is operand an INF?
2425        bne.b           _L10_4d                 # no
2426        bsr.l           szr_inf                 # yes
2427        bra.b           _L10_6d
2428_L10_4d:
2429        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2430        bne.b           _L10_5d                 # no
2431        bsr.l           src_qnan                        # yes
2432        bra.b           _L10_6d
2433_L10_5d:
2434        bsr.l           setoxd                  # operand is a DENORM
2435_L10_6d:
2436
2437#
2438#       Result is now in FP0
2439#
2440        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2441        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2442        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2443        unlk            %a6
2444        rts
2445
2446        global          _fetoxx_
2447_fetoxx_:
2448        link            %a6,&-LOCAL_SIZE
2449
2450        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2451        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2452        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2453
2454        fmov.l          &0x0,%fpcr              # zero FPCR
2455
2456#
2457#       copy, convert, and tag input argument
2458#
2459        lea             FP_SRC(%a6),%a0
2460        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
2461        mov.l           0x8+0x4(%a6),0x4(%a0)
2462        mov.l           0x8+0x8(%a6),0x8(%a0)
2463        bsr.l           tag                     # fetch operand type
2464        mov.b           %d0,STAG(%a6)
2465        mov.b           %d0,%d1
2466
2467        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2468
2469        clr.l           %d0
2470        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2471
2472        tst.b           %d1
2473        bne.b           _L10_2x
2474        bsr.l           setox                   # operand is a NORM
2475        bra.b           _L10_6x
2476_L10_2x:
2477        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2478        bne.b           _L10_3x                 # no
2479        bsr.l           ld_pone                 # yes
2480        bra.b           _L10_6x
2481_L10_3x:
2482        cmpi.b          %d1,&INF                # is operand an INF?
2483        bne.b           _L10_4x                 # no
2484        bsr.l           szr_inf                 # yes
2485        bra.b           _L10_6x
2486_L10_4x:
2487        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2488        bne.b           _L10_5x                 # no
2489        bsr.l           src_qnan                        # yes
2490        bra.b           _L10_6x
2491_L10_5x:
2492        bsr.l           setoxd                  # operand is a DENORM
2493_L10_6x:
2494
2495#
2496#       Result is now in FP0
2497#
2498        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2499        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2500        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2501        unlk            %a6
2502        rts
2503
2504
2505#########################################################################
2506# MONADIC TEMPLATE                                                      #
2507#########################################################################
2508        global          _ftwotoxs_
2509_ftwotoxs_:
2510        link            %a6,&-LOCAL_SIZE
2511
2512        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2513        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2514        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2515
2516        fmov.l          &0x0,%fpcr              # zero FPCR
2517
2518#
2519#       copy, convert, and tag input argument
2520#
2521        fmov.s          0x8(%a6),%fp0           # load sgl input
2522        fmov.x          %fp0,FP_SRC(%a6)
2523        lea             FP_SRC(%a6),%a0
2524        bsr.l           tag                     # fetch operand type
2525        mov.b           %d0,STAG(%a6)
2526        mov.b           %d0,%d1
2527
2528        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2529
2530        clr.l           %d0
2531        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2532
2533        tst.b           %d1
2534        bne.b           _L11_2s
2535        bsr.l           stwotox                 # operand is a NORM
2536        bra.b           _L11_6s
2537_L11_2s:
2538        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2539        bne.b           _L11_3s                 # no
2540        bsr.l           ld_pone                 # yes
2541        bra.b           _L11_6s
2542_L11_3s:
2543        cmpi.b          %d1,&INF                # is operand an INF?
2544        bne.b           _L11_4s                 # no
2545        bsr.l           szr_inf                 # yes
2546        bra.b           _L11_6s
2547_L11_4s:
2548        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2549        bne.b           _L11_5s                 # no
2550        bsr.l           src_qnan                        # yes
2551        bra.b           _L11_6s
2552_L11_5s:
2553        bsr.l           stwotoxd                        # operand is a DENORM
2554_L11_6s:
2555
2556#
2557#       Result is now in FP0
2558#
2559        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2560        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2561        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2562        unlk            %a6
2563        rts
2564
2565        global          _ftwotoxd_
2566_ftwotoxd_:
2567        link            %a6,&-LOCAL_SIZE
2568
2569        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2570        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2571        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2572
2573        fmov.l          &0x0,%fpcr              # zero FPCR
2574
2575#
2576#       copy, convert, and tag input argument
2577#
2578        fmov.d          0x8(%a6),%fp0           # load dbl input
2579        fmov.x          %fp0,FP_SRC(%a6)
2580        lea             FP_SRC(%a6),%a0
2581        bsr.l           tag                     # fetch operand type
2582        mov.b           %d0,STAG(%a6)
2583        mov.b           %d0,%d1
2584
2585        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2586
2587        clr.l           %d0
2588        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2589
2590        mov.b           %d1,STAG(%a6)
2591        tst.b           %d1
2592        bne.b           _L11_2d
2593        bsr.l           stwotox                 # operand is a NORM
2594        bra.b           _L11_6d
2595_L11_2d:
2596        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2597        bne.b           _L11_3d                 # no
2598        bsr.l           ld_pone                 # yes
2599        bra.b           _L11_6d
2600_L11_3d:
2601        cmpi.b          %d1,&INF                # is operand an INF?
2602        bne.b           _L11_4d                 # no
2603        bsr.l           szr_inf                 # yes
2604        bra.b           _L11_6d
2605_L11_4d:
2606        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2607        bne.b           _L11_5d                 # no
2608        bsr.l           src_qnan                        # yes
2609        bra.b           _L11_6d
2610_L11_5d:
2611        bsr.l           stwotoxd                        # operand is a DENORM
2612_L11_6d:
2613
2614#
2615#       Result is now in FP0
2616#
2617        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2618        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2619        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2620        unlk            %a6
2621        rts
2622
2623        global          _ftwotoxx_
2624_ftwotoxx_:
2625        link            %a6,&-LOCAL_SIZE
2626
2627        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2628        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2629        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2630
2631        fmov.l          &0x0,%fpcr              # zero FPCR
2632
2633#
2634#       copy, convert, and tag input argument
2635#
2636        lea             FP_SRC(%a6),%a0
2637        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
2638        mov.l           0x8+0x4(%a6),0x4(%a0)
2639        mov.l           0x8+0x8(%a6),0x8(%a0)
2640        bsr.l           tag                     # fetch operand type
2641        mov.b           %d0,STAG(%a6)
2642        mov.b           %d0,%d1
2643
2644        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2645
2646        clr.l           %d0
2647        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2648
2649        tst.b           %d1
2650        bne.b           _L11_2x
2651        bsr.l           stwotox                 # operand is a NORM
2652        bra.b           _L11_6x
2653_L11_2x:
2654        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2655        bne.b           _L11_3x                 # no
2656        bsr.l           ld_pone                 # yes
2657        bra.b           _L11_6x
2658_L11_3x:
2659        cmpi.b          %d1,&INF                # is operand an INF?
2660        bne.b           _L11_4x                 # no
2661        bsr.l           szr_inf                 # yes
2662        bra.b           _L11_6x
2663_L11_4x:
2664        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2665        bne.b           _L11_5x                 # no
2666        bsr.l           src_qnan                        # yes
2667        bra.b           _L11_6x
2668_L11_5x:
2669        bsr.l           stwotoxd                        # operand is a DENORM
2670_L11_6x:
2671
2672#
2673#       Result is now in FP0
2674#
2675        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2676        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2677        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2678        unlk            %a6
2679        rts
2680
2681
2682#########################################################################
2683# MONADIC TEMPLATE                                                      #
2684#########################################################################
2685        global          _ftentoxs_
2686_ftentoxs_:
2687        link            %a6,&-LOCAL_SIZE
2688
2689        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2690        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2691        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2692
2693        fmov.l          &0x0,%fpcr              # zero FPCR
2694
2695#
2696#       copy, convert, and tag input argument
2697#
2698        fmov.s          0x8(%a6),%fp0           # load sgl input
2699        fmov.x          %fp0,FP_SRC(%a6)
2700        lea             FP_SRC(%a6),%a0
2701        bsr.l           tag                     # fetch operand type
2702        mov.b           %d0,STAG(%a6)
2703        mov.b           %d0,%d1
2704
2705        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2706
2707        clr.l           %d0
2708        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2709
2710        tst.b           %d1
2711        bne.b           _L12_2s
2712        bsr.l           stentox                 # operand is a NORM
2713        bra.b           _L12_6s
2714_L12_2s:
2715        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2716        bne.b           _L12_3s                 # no
2717        bsr.l           ld_pone                 # yes
2718        bra.b           _L12_6s
2719_L12_3s:
2720        cmpi.b          %d1,&INF                # is operand an INF?
2721        bne.b           _L12_4s                 # no
2722        bsr.l           szr_inf                 # yes
2723        bra.b           _L12_6s
2724_L12_4s:
2725        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2726        bne.b           _L12_5s                 # no
2727        bsr.l           src_qnan                        # yes
2728        bra.b           _L12_6s
2729_L12_5s:
2730        bsr.l           stentoxd                        # operand is a DENORM
2731_L12_6s:
2732
2733#
2734#       Result is now in FP0
2735#
2736        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2737        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2738        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2739        unlk            %a6
2740        rts
2741
2742        global          _ftentoxd_
2743_ftentoxd_:
2744        link            %a6,&-LOCAL_SIZE
2745
2746        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2747        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2748        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2749
2750        fmov.l          &0x0,%fpcr              # zero FPCR
2751
2752#
2753#       copy, convert, and tag input argument
2754#
2755        fmov.d          0x8(%a6),%fp0           # load dbl input
2756        fmov.x          %fp0,FP_SRC(%a6)
2757        lea             FP_SRC(%a6),%a0
2758        bsr.l           tag                     # fetch operand type
2759        mov.b           %d0,STAG(%a6)
2760        mov.b           %d0,%d1
2761
2762        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2763
2764        clr.l           %d0
2765        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2766
2767        mov.b           %d1,STAG(%a6)
2768        tst.b           %d1
2769        bne.b           _L12_2d
2770        bsr.l           stentox                 # operand is a NORM
2771        bra.b           _L12_6d
2772_L12_2d:
2773        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2774        bne.b           _L12_3d                 # no
2775        bsr.l           ld_pone                 # yes
2776        bra.b           _L12_6d
2777_L12_3d:
2778        cmpi.b          %d1,&INF                # is operand an INF?
2779        bne.b           _L12_4d                 # no
2780        bsr.l           szr_inf                 # yes
2781        bra.b           _L12_6d
2782_L12_4d:
2783        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2784        bne.b           _L12_5d                 # no
2785        bsr.l           src_qnan                        # yes
2786        bra.b           _L12_6d
2787_L12_5d:
2788        bsr.l           stentoxd                        # operand is a DENORM
2789_L12_6d:
2790
2791#
2792#       Result is now in FP0
2793#
2794        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2795        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2796        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2797        unlk            %a6
2798        rts
2799
2800        global          _ftentoxx_
2801_ftentoxx_:
2802        link            %a6,&-LOCAL_SIZE
2803
2804        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2805        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2806        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2807
2808        fmov.l          &0x0,%fpcr              # zero FPCR
2809
2810#
2811#       copy, convert, and tag input argument
2812#
2813        lea             FP_SRC(%a6),%a0
2814        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
2815        mov.l           0x8+0x4(%a6),0x4(%a0)
2816        mov.l           0x8+0x8(%a6),0x8(%a0)
2817        bsr.l           tag                     # fetch operand type
2818        mov.b           %d0,STAG(%a6)
2819        mov.b           %d0,%d1
2820
2821        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2822
2823        clr.l           %d0
2824        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2825
2826        tst.b           %d1
2827        bne.b           _L12_2x
2828        bsr.l           stentox                 # operand is a NORM
2829        bra.b           _L12_6x
2830_L12_2x:
2831        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2832        bne.b           _L12_3x                 # no
2833        bsr.l           ld_pone                 # yes
2834        bra.b           _L12_6x
2835_L12_3x:
2836        cmpi.b          %d1,&INF                # is operand an INF?
2837        bne.b           _L12_4x                 # no
2838        bsr.l           szr_inf                 # yes
2839        bra.b           _L12_6x
2840_L12_4x:
2841        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2842        bne.b           _L12_5x                 # no
2843        bsr.l           src_qnan                        # yes
2844        bra.b           _L12_6x
2845_L12_5x:
2846        bsr.l           stentoxd                        # operand is a DENORM
2847_L12_6x:
2848
2849#
2850#       Result is now in FP0
2851#
2852        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2853        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2854        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2855        unlk            %a6
2856        rts
2857
2858
2859#########################################################################
2860# MONADIC TEMPLATE                                                      #
2861#########################################################################
2862        global          _flogns_
2863_flogns_:
2864        link            %a6,&-LOCAL_SIZE
2865
2866        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2867        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2868        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2869
2870        fmov.l          &0x0,%fpcr              # zero FPCR
2871
2872#
2873#       copy, convert, and tag input argument
2874#
2875        fmov.s          0x8(%a6),%fp0           # load sgl input
2876        fmov.x          %fp0,FP_SRC(%a6)
2877        lea             FP_SRC(%a6),%a0
2878        bsr.l           tag                     # fetch operand type
2879        mov.b           %d0,STAG(%a6)
2880        mov.b           %d0,%d1
2881
2882        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2883
2884        clr.l           %d0
2885        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2886
2887        tst.b           %d1
2888        bne.b           _L13_2s
2889        bsr.l           slogn                   # operand is a NORM
2890        bra.b           _L13_6s
2891_L13_2s:
2892        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2893        bne.b           _L13_3s                 # no
2894        bsr.l           t_dz2                   # yes
2895        bra.b           _L13_6s
2896_L13_3s:
2897        cmpi.b          %d1,&INF                # is operand an INF?
2898        bne.b           _L13_4s                 # no
2899        bsr.l           sopr_inf                        # yes
2900        bra.b           _L13_6s
2901_L13_4s:
2902        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2903        bne.b           _L13_5s                 # no
2904        bsr.l           src_qnan                        # yes
2905        bra.b           _L13_6s
2906_L13_5s:
2907        bsr.l           slognd                  # operand is a DENORM
2908_L13_6s:
2909
2910#
2911#       Result is now in FP0
2912#
2913        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2914        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2915        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2916        unlk            %a6
2917        rts
2918
2919        global          _flognd_
2920_flognd_:
2921        link            %a6,&-LOCAL_SIZE
2922
2923        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2924        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2925        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2926
2927        fmov.l          &0x0,%fpcr              # zero FPCR
2928
2929#
2930#       copy, convert, and tag input argument
2931#
2932        fmov.d          0x8(%a6),%fp0           # load dbl input
2933        fmov.x          %fp0,FP_SRC(%a6)
2934        lea             FP_SRC(%a6),%a0
2935        bsr.l           tag                     # fetch operand type
2936        mov.b           %d0,STAG(%a6)
2937        mov.b           %d0,%d1
2938
2939        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2940
2941        clr.l           %d0
2942        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
2943
2944        mov.b           %d1,STAG(%a6)
2945        tst.b           %d1
2946        bne.b           _L13_2d
2947        bsr.l           slogn                   # operand is a NORM
2948        bra.b           _L13_6d
2949_L13_2d:
2950        cmpi.b          %d1,&ZERO               # is operand a ZERO?
2951        bne.b           _L13_3d                 # no
2952        bsr.l           t_dz2                   # yes
2953        bra.b           _L13_6d
2954_L13_3d:
2955        cmpi.b          %d1,&INF                # is operand an INF?
2956        bne.b           _L13_4d                 # no
2957        bsr.l           sopr_inf                        # yes
2958        bra.b           _L13_6d
2959_L13_4d:
2960        cmpi.b          %d1,&QNAN               # is operand a QNAN?
2961        bne.b           _L13_5d                 # no
2962        bsr.l           src_qnan                        # yes
2963        bra.b           _L13_6d
2964_L13_5d:
2965        bsr.l           slognd                  # operand is a DENORM
2966_L13_6d:
2967
2968#
2969#       Result is now in FP0
2970#
2971        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
2972        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
2973        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
2974        unlk            %a6
2975        rts
2976
2977        global          _flognx_
2978_flognx_:
2979        link            %a6,&-LOCAL_SIZE
2980
2981        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
2982        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
2983        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
2984
2985        fmov.l          &0x0,%fpcr              # zero FPCR
2986
2987#
2988#       copy, convert, and tag input argument
2989#
2990        lea             FP_SRC(%a6),%a0
2991        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
2992        mov.l           0x8+0x4(%a6),0x4(%a0)
2993        mov.l           0x8+0x8(%a6),0x8(%a0)
2994        bsr.l           tag                     # fetch operand type
2995        mov.b           %d0,STAG(%a6)
2996        mov.b           %d0,%d1
2997
2998        andi.l          &0x00ff00ff,USER_FPSR(%a6)
2999
3000        clr.l           %d0
3001        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3002
3003        tst.b           %d1
3004        bne.b           _L13_2x
3005        bsr.l           slogn                   # operand is a NORM
3006        bra.b           _L13_6x
3007_L13_2x:
3008        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3009        bne.b           _L13_3x                 # no
3010        bsr.l           t_dz2                   # yes
3011        bra.b           _L13_6x
3012_L13_3x:
3013        cmpi.b          %d1,&INF                # is operand an INF?
3014        bne.b           _L13_4x                 # no
3015        bsr.l           sopr_inf                        # yes
3016        bra.b           _L13_6x
3017_L13_4x:
3018        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3019        bne.b           _L13_5x                 # no
3020        bsr.l           src_qnan                        # yes
3021        bra.b           _L13_6x
3022_L13_5x:
3023        bsr.l           slognd                  # operand is a DENORM
3024_L13_6x:
3025
3026#
3027#       Result is now in FP0
3028#
3029        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3030        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3031        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3032        unlk            %a6
3033        rts
3034
3035
3036#########################################################################
3037# MONADIC TEMPLATE                                                      #
3038#########################################################################
3039        global          _flog10s_
3040_flog10s_:
3041        link            %a6,&-LOCAL_SIZE
3042
3043        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3044        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3045        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3046
3047        fmov.l          &0x0,%fpcr              # zero FPCR
3048
3049#
3050#       copy, convert, and tag input argument
3051#
3052        fmov.s          0x8(%a6),%fp0           # load sgl input
3053        fmov.x          %fp0,FP_SRC(%a6)
3054        lea             FP_SRC(%a6),%a0
3055        bsr.l           tag                     # fetch operand type
3056        mov.b           %d0,STAG(%a6)
3057        mov.b           %d0,%d1
3058
3059        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3060
3061        clr.l           %d0
3062        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3063
3064        tst.b           %d1
3065        bne.b           _L14_2s
3066        bsr.l           slog10                  # operand is a NORM
3067        bra.b           _L14_6s
3068_L14_2s:
3069        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3070        bne.b           _L14_3s                 # no
3071        bsr.l           t_dz2                   # yes
3072        bra.b           _L14_6s
3073_L14_3s:
3074        cmpi.b          %d1,&INF                # is operand an INF?
3075        bne.b           _L14_4s                 # no
3076        bsr.l           sopr_inf                        # yes
3077        bra.b           _L14_6s
3078_L14_4s:
3079        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3080        bne.b           _L14_5s                 # no
3081        bsr.l           src_qnan                        # yes
3082        bra.b           _L14_6s
3083_L14_5s:
3084        bsr.l           slog10d                 # operand is a DENORM
3085_L14_6s:
3086
3087#
3088#       Result is now in FP0
3089#
3090        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3091        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3092        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3093        unlk            %a6
3094        rts
3095
3096        global          _flog10d_
3097_flog10d_:
3098        link            %a6,&-LOCAL_SIZE
3099
3100        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3101        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3102        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3103
3104        fmov.l          &0x0,%fpcr              # zero FPCR
3105
3106#
3107#       copy, convert, and tag input argument
3108#
3109        fmov.d          0x8(%a6),%fp0           # load dbl input
3110        fmov.x          %fp0,FP_SRC(%a6)
3111        lea             FP_SRC(%a6),%a0
3112        bsr.l           tag                     # fetch operand type
3113        mov.b           %d0,STAG(%a6)
3114        mov.b           %d0,%d1
3115
3116        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3117
3118        clr.l           %d0
3119        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3120
3121        mov.b           %d1,STAG(%a6)
3122        tst.b           %d1
3123        bne.b           _L14_2d
3124        bsr.l           slog10                  # operand is a NORM
3125        bra.b           _L14_6d
3126_L14_2d:
3127        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3128        bne.b           _L14_3d                 # no
3129        bsr.l           t_dz2                   # yes
3130        bra.b           _L14_6d
3131_L14_3d:
3132        cmpi.b          %d1,&INF                # is operand an INF?
3133        bne.b           _L14_4d                 # no
3134        bsr.l           sopr_inf                        # yes
3135        bra.b           _L14_6d
3136_L14_4d:
3137        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3138        bne.b           _L14_5d                 # no
3139        bsr.l           src_qnan                        # yes
3140        bra.b           _L14_6d
3141_L14_5d:
3142        bsr.l           slog10d                 # operand is a DENORM
3143_L14_6d:
3144
3145#
3146#       Result is now in FP0
3147#
3148        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3149        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3150        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3151        unlk            %a6
3152        rts
3153
3154        global          _flog10x_
3155_flog10x_:
3156        link            %a6,&-LOCAL_SIZE
3157
3158        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3159        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3160        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3161
3162        fmov.l          &0x0,%fpcr              # zero FPCR
3163
3164#
3165#       copy, convert, and tag input argument
3166#
3167        lea             FP_SRC(%a6),%a0
3168        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
3169        mov.l           0x8+0x4(%a6),0x4(%a0)
3170        mov.l           0x8+0x8(%a6),0x8(%a0)
3171        bsr.l           tag                     # fetch operand type
3172        mov.b           %d0,STAG(%a6)
3173        mov.b           %d0,%d1
3174
3175        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3176
3177        clr.l           %d0
3178        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3179
3180        tst.b           %d1
3181        bne.b           _L14_2x
3182        bsr.l           slog10                  # operand is a NORM
3183        bra.b           _L14_6x
3184_L14_2x:
3185        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3186        bne.b           _L14_3x                 # no
3187        bsr.l           t_dz2                   # yes
3188        bra.b           _L14_6x
3189_L14_3x:
3190        cmpi.b          %d1,&INF                # is operand an INF?
3191        bne.b           _L14_4x                 # no
3192        bsr.l           sopr_inf                        # yes
3193        bra.b           _L14_6x
3194_L14_4x:
3195        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3196        bne.b           _L14_5x                 # no
3197        bsr.l           src_qnan                        # yes
3198        bra.b           _L14_6x
3199_L14_5x:
3200        bsr.l           slog10d                 # operand is a DENORM
3201_L14_6x:
3202
3203#
3204#       Result is now in FP0
3205#
3206        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3207        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3208        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3209        unlk            %a6
3210        rts
3211
3212
3213#########################################################################
3214# MONADIC TEMPLATE                                                      #
3215#########################################################################
3216        global          _flog2s_
3217_flog2s_:
3218        link            %a6,&-LOCAL_SIZE
3219
3220        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3221        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3222        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3223
3224        fmov.l          &0x0,%fpcr              # zero FPCR
3225
3226#
3227#       copy, convert, and tag input argument
3228#
3229        fmov.s          0x8(%a6),%fp0           # load sgl input
3230        fmov.x          %fp0,FP_SRC(%a6)
3231        lea             FP_SRC(%a6),%a0
3232        bsr.l           tag                     # fetch operand type
3233        mov.b           %d0,STAG(%a6)
3234        mov.b           %d0,%d1
3235
3236        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3237
3238        clr.l           %d0
3239        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3240
3241        tst.b           %d1
3242        bne.b           _L15_2s
3243        bsr.l           slog2                   # operand is a NORM
3244        bra.b           _L15_6s
3245_L15_2s:
3246        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3247        bne.b           _L15_3s                 # no
3248        bsr.l           t_dz2                   # yes
3249        bra.b           _L15_6s
3250_L15_3s:
3251        cmpi.b          %d1,&INF                # is operand an INF?
3252        bne.b           _L15_4s                 # no
3253        bsr.l           sopr_inf                        # yes
3254        bra.b           _L15_6s
3255_L15_4s:
3256        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3257        bne.b           _L15_5s                 # no
3258        bsr.l           src_qnan                        # yes
3259        bra.b           _L15_6s
3260_L15_5s:
3261        bsr.l           slog2d                  # operand is a DENORM
3262_L15_6s:
3263
3264#
3265#       Result is now in FP0
3266#
3267        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3268        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3269        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3270        unlk            %a6
3271        rts
3272
3273        global          _flog2d_
3274_flog2d_:
3275        link            %a6,&-LOCAL_SIZE
3276
3277        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3278        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3279        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3280
3281        fmov.l          &0x0,%fpcr              # zero FPCR
3282
3283#
3284#       copy, convert, and tag input argument
3285#
3286        fmov.d          0x8(%a6),%fp0           # load dbl input
3287        fmov.x          %fp0,FP_SRC(%a6)
3288        lea             FP_SRC(%a6),%a0
3289        bsr.l           tag                     # fetch operand type
3290        mov.b           %d0,STAG(%a6)
3291        mov.b           %d0,%d1
3292
3293        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3294
3295        clr.l           %d0
3296        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3297
3298        mov.b           %d1,STAG(%a6)
3299        tst.b           %d1
3300        bne.b           _L15_2d
3301        bsr.l           slog2                   # operand is a NORM
3302        bra.b           _L15_6d
3303_L15_2d:
3304        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3305        bne.b           _L15_3d                 # no
3306        bsr.l           t_dz2                   # yes
3307        bra.b           _L15_6d
3308_L15_3d:
3309        cmpi.b          %d1,&INF                # is operand an INF?
3310        bne.b           _L15_4d                 # no
3311        bsr.l           sopr_inf                        # yes
3312        bra.b           _L15_6d
3313_L15_4d:
3314        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3315        bne.b           _L15_5d                 # no
3316        bsr.l           src_qnan                        # yes
3317        bra.b           _L15_6d
3318_L15_5d:
3319        bsr.l           slog2d                  # operand is a DENORM
3320_L15_6d:
3321
3322#
3323#       Result is now in FP0
3324#
3325        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3326        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3327        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3328        unlk            %a6
3329        rts
3330
3331        global          _flog2x_
3332_flog2x_:
3333        link            %a6,&-LOCAL_SIZE
3334
3335        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3336        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3337        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3338
3339        fmov.l          &0x0,%fpcr              # zero FPCR
3340
3341#
3342#       copy, convert, and tag input argument
3343#
3344        lea             FP_SRC(%a6),%a0
3345        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
3346        mov.l           0x8+0x4(%a6),0x4(%a0)
3347        mov.l           0x8+0x8(%a6),0x8(%a0)
3348        bsr.l           tag                     # fetch operand type
3349        mov.b           %d0,STAG(%a6)
3350        mov.b           %d0,%d1
3351
3352        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3353
3354        clr.l           %d0
3355        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3356
3357        tst.b           %d1
3358        bne.b           _L15_2x
3359        bsr.l           slog2                   # operand is a NORM
3360        bra.b           _L15_6x
3361_L15_2x:
3362        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3363        bne.b           _L15_3x                 # no
3364        bsr.l           t_dz2                   # yes
3365        bra.b           _L15_6x
3366_L15_3x:
3367        cmpi.b          %d1,&INF                # is operand an INF?
3368        bne.b           _L15_4x                 # no
3369        bsr.l           sopr_inf                        # yes
3370        bra.b           _L15_6x
3371_L15_4x:
3372        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3373        bne.b           _L15_5x                 # no
3374        bsr.l           src_qnan                        # yes
3375        bra.b           _L15_6x
3376_L15_5x:
3377        bsr.l           slog2d                  # operand is a DENORM
3378_L15_6x:
3379
3380#
3381#       Result is now in FP0
3382#
3383        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3384        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3385        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3386        unlk            %a6
3387        rts
3388
3389
3390#########################################################################
3391# MONADIC TEMPLATE                                                      #
3392#########################################################################
3393        global          _fcoshs_
3394_fcoshs_:
3395        link            %a6,&-LOCAL_SIZE
3396
3397        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3398        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3399        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3400
3401        fmov.l          &0x0,%fpcr              # zero FPCR
3402
3403#
3404#       copy, convert, and tag input argument
3405#
3406        fmov.s          0x8(%a6),%fp0           # load sgl input
3407        fmov.x          %fp0,FP_SRC(%a6)
3408        lea             FP_SRC(%a6),%a0
3409        bsr.l           tag                     # fetch operand type
3410        mov.b           %d0,STAG(%a6)
3411        mov.b           %d0,%d1
3412
3413        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3414
3415        clr.l           %d0
3416        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3417
3418        tst.b           %d1
3419        bne.b           _L16_2s
3420        bsr.l           scosh                   # operand is a NORM
3421        bra.b           _L16_6s
3422_L16_2s:
3423        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3424        bne.b           _L16_3s                 # no
3425        bsr.l           ld_pone                 # yes
3426        bra.b           _L16_6s
3427_L16_3s:
3428        cmpi.b          %d1,&INF                # is operand an INF?
3429        bne.b           _L16_4s                 # no
3430        bsr.l           ld_pinf                 # yes
3431        bra.b           _L16_6s
3432_L16_4s:
3433        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3434        bne.b           _L16_5s                 # no
3435        bsr.l           src_qnan                        # yes
3436        bra.b           _L16_6s
3437_L16_5s:
3438        bsr.l           scoshd                  # operand is a DENORM
3439_L16_6s:
3440
3441#
3442#       Result is now in FP0
3443#
3444        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3445        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3446        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3447        unlk            %a6
3448        rts
3449
3450        global          _fcoshd_
3451_fcoshd_:
3452        link            %a6,&-LOCAL_SIZE
3453
3454        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3455        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3456        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3457
3458        fmov.l          &0x0,%fpcr              # zero FPCR
3459
3460#
3461#       copy, convert, and tag input argument
3462#
3463        fmov.d          0x8(%a6),%fp0           # load dbl input
3464        fmov.x          %fp0,FP_SRC(%a6)
3465        lea             FP_SRC(%a6),%a0
3466        bsr.l           tag                     # fetch operand type
3467        mov.b           %d0,STAG(%a6)
3468        mov.b           %d0,%d1
3469
3470        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3471
3472        clr.l           %d0
3473        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3474
3475        mov.b           %d1,STAG(%a6)
3476        tst.b           %d1
3477        bne.b           _L16_2d
3478        bsr.l           scosh                   # operand is a NORM
3479        bra.b           _L16_6d
3480_L16_2d:
3481        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3482        bne.b           _L16_3d                 # no
3483        bsr.l           ld_pone                 # yes
3484        bra.b           _L16_6d
3485_L16_3d:
3486        cmpi.b          %d1,&INF                # is operand an INF?
3487        bne.b           _L16_4d                 # no
3488        bsr.l           ld_pinf                 # yes
3489        bra.b           _L16_6d
3490_L16_4d:
3491        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3492        bne.b           _L16_5d                 # no
3493        bsr.l           src_qnan                        # yes
3494        bra.b           _L16_6d
3495_L16_5d:
3496        bsr.l           scoshd                  # operand is a DENORM
3497_L16_6d:
3498
3499#
3500#       Result is now in FP0
3501#
3502        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3503        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3504        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3505        unlk            %a6
3506        rts
3507
3508        global          _fcoshx_
3509_fcoshx_:
3510        link            %a6,&-LOCAL_SIZE
3511
3512        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3513        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3514        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3515
3516        fmov.l          &0x0,%fpcr              # zero FPCR
3517
3518#
3519#       copy, convert, and tag input argument
3520#
3521        lea             FP_SRC(%a6),%a0
3522        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
3523        mov.l           0x8+0x4(%a6),0x4(%a0)
3524        mov.l           0x8+0x8(%a6),0x8(%a0)
3525        bsr.l           tag                     # fetch operand type
3526        mov.b           %d0,STAG(%a6)
3527        mov.b           %d0,%d1
3528
3529        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3530
3531        clr.l           %d0
3532        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3533
3534        tst.b           %d1
3535        bne.b           _L16_2x
3536        bsr.l           scosh                   # operand is a NORM
3537        bra.b           _L16_6x
3538_L16_2x:
3539        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3540        bne.b           _L16_3x                 # no
3541        bsr.l           ld_pone                 # yes
3542        bra.b           _L16_6x
3543_L16_3x:
3544        cmpi.b          %d1,&INF                # is operand an INF?
3545        bne.b           _L16_4x                 # no
3546        bsr.l           ld_pinf                 # yes
3547        bra.b           _L16_6x
3548_L16_4x:
3549        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3550        bne.b           _L16_5x                 # no
3551        bsr.l           src_qnan                        # yes
3552        bra.b           _L16_6x
3553_L16_5x:
3554        bsr.l           scoshd                  # operand is a DENORM
3555_L16_6x:
3556
3557#
3558#       Result is now in FP0
3559#
3560        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3561        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3562        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3563        unlk            %a6
3564        rts
3565
3566
3567#########################################################################
3568# MONADIC TEMPLATE                                                      #
3569#########################################################################
3570        global          _facoss_
3571_facoss_:
3572        link            %a6,&-LOCAL_SIZE
3573
3574        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3575        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3576        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3577
3578        fmov.l          &0x0,%fpcr              # zero FPCR
3579
3580#
3581#       copy, convert, and tag input argument
3582#
3583        fmov.s          0x8(%a6),%fp0           # load sgl input
3584        fmov.x          %fp0,FP_SRC(%a6)
3585        lea             FP_SRC(%a6),%a0
3586        bsr.l           tag                     # fetch operand type
3587        mov.b           %d0,STAG(%a6)
3588        mov.b           %d0,%d1
3589
3590        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3591
3592        clr.l           %d0
3593        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3594
3595        tst.b           %d1
3596        bne.b           _L17_2s
3597        bsr.l           sacos                   # operand is a NORM
3598        bra.b           _L17_6s
3599_L17_2s:
3600        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3601        bne.b           _L17_3s                 # no
3602        bsr.l           ld_ppi2                 # yes
3603        bra.b           _L17_6s
3604_L17_3s:
3605        cmpi.b          %d1,&INF                # is operand an INF?
3606        bne.b           _L17_4s                 # no
3607        bsr.l           t_operr                 # yes
3608        bra.b           _L17_6s
3609_L17_4s:
3610        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3611        bne.b           _L17_5s                 # no
3612        bsr.l           src_qnan                        # yes
3613        bra.b           _L17_6s
3614_L17_5s:
3615        bsr.l           sacosd                  # operand is a DENORM
3616_L17_6s:
3617
3618#
3619#       Result is now in FP0
3620#
3621        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3622        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3623        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3624        unlk            %a6
3625        rts
3626
3627        global          _facosd_
3628_facosd_:
3629        link            %a6,&-LOCAL_SIZE
3630
3631        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3632        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3633        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3634
3635        fmov.l          &0x0,%fpcr              # zero FPCR
3636
3637#
3638#       copy, convert, and tag input argument
3639#
3640        fmov.d          0x8(%a6),%fp0           # load dbl input
3641        fmov.x          %fp0,FP_SRC(%a6)
3642        lea             FP_SRC(%a6),%a0
3643        bsr.l           tag                     # fetch operand type
3644        mov.b           %d0,STAG(%a6)
3645        mov.b           %d0,%d1
3646
3647        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3648
3649        clr.l           %d0
3650        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3651
3652        mov.b           %d1,STAG(%a6)
3653        tst.b           %d1
3654        bne.b           _L17_2d
3655        bsr.l           sacos                   # operand is a NORM
3656        bra.b           _L17_6d
3657_L17_2d:
3658        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3659        bne.b           _L17_3d                 # no
3660        bsr.l           ld_ppi2                 # yes
3661        bra.b           _L17_6d
3662_L17_3d:
3663        cmpi.b          %d1,&INF                # is operand an INF?
3664        bne.b           _L17_4d                 # no
3665        bsr.l           t_operr                 # yes
3666        bra.b           _L17_6d
3667_L17_4d:
3668        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3669        bne.b           _L17_5d                 # no
3670        bsr.l           src_qnan                        # yes
3671        bra.b           _L17_6d
3672_L17_5d:
3673        bsr.l           sacosd                  # operand is a DENORM
3674_L17_6d:
3675
3676#
3677#       Result is now in FP0
3678#
3679        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3680        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3681        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3682        unlk            %a6
3683        rts
3684
3685        global          _facosx_
3686_facosx_:
3687        link            %a6,&-LOCAL_SIZE
3688
3689        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3690        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3691        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3692
3693        fmov.l          &0x0,%fpcr              # zero FPCR
3694
3695#
3696#       copy, convert, and tag input argument
3697#
3698        lea             FP_SRC(%a6),%a0
3699        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
3700        mov.l           0x8+0x4(%a6),0x4(%a0)
3701        mov.l           0x8+0x8(%a6),0x8(%a0)
3702        bsr.l           tag                     # fetch operand type
3703        mov.b           %d0,STAG(%a6)
3704        mov.b           %d0,%d1
3705
3706        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3707
3708        clr.l           %d0
3709        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3710
3711        tst.b           %d1
3712        bne.b           _L17_2x
3713        bsr.l           sacos                   # operand is a NORM
3714        bra.b           _L17_6x
3715_L17_2x:
3716        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3717        bne.b           _L17_3x                 # no
3718        bsr.l           ld_ppi2                 # yes
3719        bra.b           _L17_6x
3720_L17_3x:
3721        cmpi.b          %d1,&INF                # is operand an INF?
3722        bne.b           _L17_4x                 # no
3723        bsr.l           t_operr                 # yes
3724        bra.b           _L17_6x
3725_L17_4x:
3726        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3727        bne.b           _L17_5x                 # no
3728        bsr.l           src_qnan                        # yes
3729        bra.b           _L17_6x
3730_L17_5x:
3731        bsr.l           sacosd                  # operand is a DENORM
3732_L17_6x:
3733
3734#
3735#       Result is now in FP0
3736#
3737        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3738        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3739        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3740        unlk            %a6
3741        rts
3742
3743
3744#########################################################################
3745# MONADIC TEMPLATE                                                      #
3746#########################################################################
3747        global          _fgetexps_
3748_fgetexps_:
3749        link            %a6,&-LOCAL_SIZE
3750
3751        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3752        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3753        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3754
3755        fmov.l          &0x0,%fpcr              # zero FPCR
3756
3757#
3758#       copy, convert, and tag input argument
3759#
3760        fmov.s          0x8(%a6),%fp0           # load sgl input
3761        fmov.x          %fp0,FP_SRC(%a6)
3762        lea             FP_SRC(%a6),%a0
3763        bsr.l           tag                     # fetch operand type
3764        mov.b           %d0,STAG(%a6)
3765        mov.b           %d0,%d1
3766
3767        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3768
3769        clr.l           %d0
3770        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3771
3772        tst.b           %d1
3773        bne.b           _L18_2s
3774        bsr.l           sgetexp                 # operand is a NORM
3775        bra.b           _L18_6s
3776_L18_2s:
3777        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3778        bne.b           _L18_3s                 # no
3779        bsr.l           src_zero                        # yes
3780        bra.b           _L18_6s
3781_L18_3s:
3782        cmpi.b          %d1,&INF                # is operand an INF?
3783        bne.b           _L18_4s                 # no
3784        bsr.l           t_operr                 # yes
3785        bra.b           _L18_6s
3786_L18_4s:
3787        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3788        bne.b           _L18_5s                 # no
3789        bsr.l           src_qnan                        # yes
3790        bra.b           _L18_6s
3791_L18_5s:
3792        bsr.l           sgetexpd                        # operand is a DENORM
3793_L18_6s:
3794
3795#
3796#       Result is now in FP0
3797#
3798        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3799        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3800        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3801        unlk            %a6
3802        rts
3803
3804        global          _fgetexpd_
3805_fgetexpd_:
3806        link            %a6,&-LOCAL_SIZE
3807
3808        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3809        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3810        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3811
3812        fmov.l          &0x0,%fpcr              # zero FPCR
3813
3814#
3815#       copy, convert, and tag input argument
3816#
3817        fmov.d          0x8(%a6),%fp0           # load dbl input
3818        fmov.x          %fp0,FP_SRC(%a6)
3819        lea             FP_SRC(%a6),%a0
3820        bsr.l           tag                     # fetch operand type
3821        mov.b           %d0,STAG(%a6)
3822        mov.b           %d0,%d1
3823
3824        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3825
3826        clr.l           %d0
3827        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3828
3829        mov.b           %d1,STAG(%a6)
3830        tst.b           %d1
3831        bne.b           _L18_2d
3832        bsr.l           sgetexp                 # operand is a NORM
3833        bra.b           _L18_6d
3834_L18_2d:
3835        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3836        bne.b           _L18_3d                 # no
3837        bsr.l           src_zero                        # yes
3838        bra.b           _L18_6d
3839_L18_3d:
3840        cmpi.b          %d1,&INF                # is operand an INF?
3841        bne.b           _L18_4d                 # no
3842        bsr.l           t_operr                 # yes
3843        bra.b           _L18_6d
3844_L18_4d:
3845        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3846        bne.b           _L18_5d                 # no
3847        bsr.l           src_qnan                        # yes
3848        bra.b           _L18_6d
3849_L18_5d:
3850        bsr.l           sgetexpd                        # operand is a DENORM
3851_L18_6d:
3852
3853#
3854#       Result is now in FP0
3855#
3856        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3857        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3858        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3859        unlk            %a6
3860        rts
3861
3862        global          _fgetexpx_
3863_fgetexpx_:
3864        link            %a6,&-LOCAL_SIZE
3865
3866        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3867        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3868        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3869
3870        fmov.l          &0x0,%fpcr              # zero FPCR
3871
3872#
3873#       copy, convert, and tag input argument
3874#
3875        lea             FP_SRC(%a6),%a0
3876        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
3877        mov.l           0x8+0x4(%a6),0x4(%a0)
3878        mov.l           0x8+0x8(%a6),0x8(%a0)
3879        bsr.l           tag                     # fetch operand type
3880        mov.b           %d0,STAG(%a6)
3881        mov.b           %d0,%d1
3882
3883        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3884
3885        clr.l           %d0
3886        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3887
3888        tst.b           %d1
3889        bne.b           _L18_2x
3890        bsr.l           sgetexp                 # operand is a NORM
3891        bra.b           _L18_6x
3892_L18_2x:
3893        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3894        bne.b           _L18_3x                 # no
3895        bsr.l           src_zero                        # yes
3896        bra.b           _L18_6x
3897_L18_3x:
3898        cmpi.b          %d1,&INF                # is operand an INF?
3899        bne.b           _L18_4x                 # no
3900        bsr.l           t_operr                 # yes
3901        bra.b           _L18_6x
3902_L18_4x:
3903        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3904        bne.b           _L18_5x                 # no
3905        bsr.l           src_qnan                        # yes
3906        bra.b           _L18_6x
3907_L18_5x:
3908        bsr.l           sgetexpd                        # operand is a DENORM
3909_L18_6x:
3910
3911#
3912#       Result is now in FP0
3913#
3914        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3915        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3916        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3917        unlk            %a6
3918        rts
3919
3920
3921#########################################################################
3922# MONADIC TEMPLATE                                                      #
3923#########################################################################
3924        global          _fgetmans_
3925_fgetmans_:
3926        link            %a6,&-LOCAL_SIZE
3927
3928        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3929        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3930        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3931
3932        fmov.l          &0x0,%fpcr              # zero FPCR
3933
3934#
3935#       copy, convert, and tag input argument
3936#
3937        fmov.s          0x8(%a6),%fp0           # load sgl input
3938        fmov.x          %fp0,FP_SRC(%a6)
3939        lea             FP_SRC(%a6),%a0
3940        bsr.l           tag                     # fetch operand type
3941        mov.b           %d0,STAG(%a6)
3942        mov.b           %d0,%d1
3943
3944        andi.l          &0x00ff00ff,USER_FPSR(%a6)
3945
3946        clr.l           %d0
3947        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
3948
3949        tst.b           %d1
3950        bne.b           _L19_2s
3951        bsr.l           sgetman                 # operand is a NORM
3952        bra.b           _L19_6s
3953_L19_2s:
3954        cmpi.b          %d1,&ZERO               # is operand a ZERO?
3955        bne.b           _L19_3s                 # no
3956        bsr.l           src_zero                        # yes
3957        bra.b           _L19_6s
3958_L19_3s:
3959        cmpi.b          %d1,&INF                # is operand an INF?
3960        bne.b           _L19_4s                 # no
3961        bsr.l           t_operr                 # yes
3962        bra.b           _L19_6s
3963_L19_4s:
3964        cmpi.b          %d1,&QNAN               # is operand a QNAN?
3965        bne.b           _L19_5s                 # no
3966        bsr.l           src_qnan                        # yes
3967        bra.b           _L19_6s
3968_L19_5s:
3969        bsr.l           sgetmand                        # operand is a DENORM
3970_L19_6s:
3971
3972#
3973#       Result is now in FP0
3974#
3975        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
3976        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
3977        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
3978        unlk            %a6
3979        rts
3980
3981        global          _fgetmand_
3982_fgetmand_:
3983        link            %a6,&-LOCAL_SIZE
3984
3985        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
3986        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
3987        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
3988
3989        fmov.l          &0x0,%fpcr              # zero FPCR
3990
3991#
3992#       copy, convert, and tag input argument
3993#
3994        fmov.d          0x8(%a6),%fp0           # load dbl input
3995        fmov.x          %fp0,FP_SRC(%a6)
3996        lea             FP_SRC(%a6),%a0
3997        bsr.l           tag                     # fetch operand type
3998        mov.b           %d0,STAG(%a6)
3999        mov.b           %d0,%d1
4000
4001        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4002
4003        clr.l           %d0
4004        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4005
4006        mov.b           %d1,STAG(%a6)
4007        tst.b           %d1
4008        bne.b           _L19_2d
4009        bsr.l           sgetman                 # operand is a NORM
4010        bra.b           _L19_6d
4011_L19_2d:
4012        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4013        bne.b           _L19_3d                 # no
4014        bsr.l           src_zero                        # yes
4015        bra.b           _L19_6d
4016_L19_3d:
4017        cmpi.b          %d1,&INF                # is operand an INF?
4018        bne.b           _L19_4d                 # no
4019        bsr.l           t_operr                 # yes
4020        bra.b           _L19_6d
4021_L19_4d:
4022        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4023        bne.b           _L19_5d                 # no
4024        bsr.l           src_qnan                        # yes
4025        bra.b           _L19_6d
4026_L19_5d:
4027        bsr.l           sgetmand                        # operand is a DENORM
4028_L19_6d:
4029
4030#
4031#       Result is now in FP0
4032#
4033        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4034        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4035        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4036        unlk            %a6
4037        rts
4038
4039        global          _fgetmanx_
4040_fgetmanx_:
4041        link            %a6,&-LOCAL_SIZE
4042
4043        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4044        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4045        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4046
4047        fmov.l          &0x0,%fpcr              # zero FPCR
4048
4049#
4050#       copy, convert, and tag input argument
4051#
4052        lea             FP_SRC(%a6),%a0
4053        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
4054        mov.l           0x8+0x4(%a6),0x4(%a0)
4055        mov.l           0x8+0x8(%a6),0x8(%a0)
4056        bsr.l           tag                     # fetch operand type
4057        mov.b           %d0,STAG(%a6)
4058        mov.b           %d0,%d1
4059
4060        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4061
4062        clr.l           %d0
4063        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4064
4065        tst.b           %d1
4066        bne.b           _L19_2x
4067        bsr.l           sgetman                 # operand is a NORM
4068        bra.b           _L19_6x
4069_L19_2x:
4070        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4071        bne.b           _L19_3x                 # no
4072        bsr.l           src_zero                        # yes
4073        bra.b           _L19_6x
4074_L19_3x:
4075        cmpi.b          %d1,&INF                # is operand an INF?
4076        bne.b           _L19_4x                 # no
4077        bsr.l           t_operr                 # yes
4078        bra.b           _L19_6x
4079_L19_4x:
4080        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4081        bne.b           _L19_5x                 # no
4082        bsr.l           src_qnan                        # yes
4083        bra.b           _L19_6x
4084_L19_5x:
4085        bsr.l           sgetmand                        # operand is a DENORM
4086_L19_6x:
4087
4088#
4089#       Result is now in FP0
4090#
4091        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4092        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4093        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4094        unlk            %a6
4095        rts
4096
4097
4098#########################################################################
4099# MONADIC TEMPLATE                                                      #
4100#########################################################################
4101        global          _fsincoss_
4102_fsincoss_:
4103        link            %a6,&-LOCAL_SIZE
4104
4105        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4106        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4107        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4108
4109        fmov.l          &0x0,%fpcr              # zero FPCR
4110
4111#
4112#       copy, convert, and tag input argument
4113#
4114        fmov.s          0x8(%a6),%fp0           # load sgl input
4115        fmov.x          %fp0,FP_SRC(%a6)
4116        lea             FP_SRC(%a6),%a0
4117        bsr.l           tag                     # fetch operand type
4118        mov.b           %d0,STAG(%a6)
4119        mov.b           %d0,%d1
4120
4121        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4122
4123        clr.l           %d0
4124        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4125
4126        tst.b           %d1
4127        bne.b           _L20_2s
4128        bsr.l           ssincos                 # operand is a NORM
4129        bra.b           _L20_6s
4130_L20_2s:
4131        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4132        bne.b           _L20_3s                 # no
4133        bsr.l           ssincosz                        # yes
4134        bra.b           _L20_6s
4135_L20_3s:
4136        cmpi.b          %d1,&INF                # is operand an INF?
4137        bne.b           _L20_4s                 # no
4138        bsr.l           ssincosi                        # yes
4139        bra.b           _L20_6s
4140_L20_4s:
4141        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4142        bne.b           _L20_5s                 # no
4143        bsr.l           ssincosqnan                     # yes
4144        bra.b           _L20_6s
4145_L20_5s:
4146        bsr.l           ssincosd                        # operand is a DENORM
4147_L20_6s:
4148
4149#
4150#       Result is now in FP0
4151#
4152        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4153        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4154        fmovm.x         &0x03,-(%sp)            # store off fp0/fp1
4155        fmovm.x         (%sp)+,&0x40            # fp0 now in fp1
4156        fmovm.x         (%sp)+,&0x80            # fp1 now in fp0
4157        unlk            %a6
4158        rts
4159
4160        global          _fsincosd_
4161_fsincosd_:
4162        link            %a6,&-LOCAL_SIZE
4163
4164        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4165        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4166        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4167
4168        fmov.l          &0x0,%fpcr              # zero FPCR
4169
4170#
4171#       copy, convert, and tag input argument
4172#
4173        fmov.d          0x8(%a6),%fp0           # load dbl input
4174        fmov.x          %fp0,FP_SRC(%a6)
4175        lea             FP_SRC(%a6),%a0
4176        bsr.l           tag                     # fetch operand type
4177        mov.b           %d0,STAG(%a6)
4178        mov.b           %d0,%d1
4179
4180        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4181
4182        clr.l           %d0
4183        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4184
4185        mov.b           %d1,STAG(%a6)
4186        tst.b           %d1
4187        bne.b           _L20_2d
4188        bsr.l           ssincos                 # operand is a NORM
4189        bra.b           _L20_6d
4190_L20_2d:
4191        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4192        bne.b           _L20_3d                 # no
4193        bsr.l           ssincosz                        # yes
4194        bra.b           _L20_6d
4195_L20_3d:
4196        cmpi.b          %d1,&INF                # is operand an INF?
4197        bne.b           _L20_4d                 # no
4198        bsr.l           ssincosi                        # yes
4199        bra.b           _L20_6d
4200_L20_4d:
4201        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4202        bne.b           _L20_5d                 # no
4203        bsr.l           ssincosqnan                     # yes
4204        bra.b           _L20_6d
4205_L20_5d:
4206        bsr.l           ssincosd                        # operand is a DENORM
4207_L20_6d:
4208
4209#
4210#       Result is now in FP0
4211#
4212        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4213        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4214        fmovm.x         &0x03,-(%sp)            # store off fp0/fp1
4215        fmovm.x         (%sp)+,&0x40            # fp0 now in fp1
4216        fmovm.x         (%sp)+,&0x80            # fp1 now in fp0
4217        unlk            %a6
4218        rts
4219
4220        global          _fsincosx_
4221_fsincosx_:
4222        link            %a6,&-LOCAL_SIZE
4223
4224        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4225        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4226        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4227
4228        fmov.l          &0x0,%fpcr              # zero FPCR
4229
4230#
4231#       copy, convert, and tag input argument
4232#
4233        lea             FP_SRC(%a6),%a0
4234        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext input
4235        mov.l           0x8+0x4(%a6),0x4(%a0)
4236        mov.l           0x8+0x8(%a6),0x8(%a0)
4237        bsr.l           tag                     # fetch operand type
4238        mov.b           %d0,STAG(%a6)
4239        mov.b           %d0,%d1
4240
4241        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4242
4243        clr.l           %d0
4244        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4245
4246        tst.b           %d1
4247        bne.b           _L20_2x
4248        bsr.l           ssincos                 # operand is a NORM
4249        bra.b           _L20_6x
4250_L20_2x:
4251        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4252        bne.b           _L20_3x                 # no
4253        bsr.l           ssincosz                        # yes
4254        bra.b           _L20_6x
4255_L20_3x:
4256        cmpi.b          %d1,&INF                # is operand an INF?
4257        bne.b           _L20_4x                 # no
4258        bsr.l           ssincosi                        # yes
4259        bra.b           _L20_6x
4260_L20_4x:
4261        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4262        bne.b           _L20_5x                 # no
4263        bsr.l           ssincosqnan                     # yes
4264        bra.b           _L20_6x
4265_L20_5x:
4266        bsr.l           ssincosd                        # operand is a DENORM
4267_L20_6x:
4268
4269#
4270#       Result is now in FP0
4271#
4272        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4273        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4274        fmovm.x         &0x03,-(%sp)            # store off fp0/fp1
4275        fmovm.x         (%sp)+,&0x40            # fp0 now in fp1
4276        fmovm.x         (%sp)+,&0x80            # fp1 now in fp0
4277        unlk            %a6
4278        rts
4279
4280
4281#########################################################################
4282# DYADIC TEMPLATE                                                       #
4283#########################################################################
4284        global          _frems_
4285_frems_:
4286        link            %a6,&-LOCAL_SIZE
4287
4288        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4289        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4290        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4291
4292        fmov.l          &0x0,%fpcr              # zero FPCR
4293
4294#
4295#       copy, convert, and tag input argument
4296#
4297        fmov.s          0x8(%a6),%fp0           # load sgl dst
4298        fmov.x          %fp0,FP_DST(%a6)
4299        lea             FP_DST(%a6),%a0
4300        bsr.l           tag                     # fetch operand type
4301        mov.b           %d0,DTAG(%a6)
4302
4303        fmov.s          0xc(%a6),%fp0           # load sgl src
4304        fmov.x          %fp0,FP_SRC(%a6)
4305        lea             FP_SRC(%a6),%a0
4306        bsr.l           tag                     # fetch operand type
4307        mov.b           %d0,STAG(%a6)
4308        mov.l           %d0,%d1
4309
4310        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4311
4312        clr.l           %d0
4313        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4314
4315        lea             FP_SRC(%a6),%a0         # pass ptr to src
4316        lea             FP_DST(%a6),%a1         # pass ptr to dst
4317
4318        tst.b           %d1
4319        bne.b           _L21_2s
4320        bsr.l           srem_snorm                      # operand is a NORM
4321        bra.b           _L21_6s
4322_L21_2s:
4323        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4324        bne.b           _L21_3s                 # no
4325        bsr.l           srem_szero                      # yes
4326        bra.b           _L21_6s
4327_L21_3s:
4328        cmpi.b          %d1,&INF                # is operand an INF?
4329        bne.b           _L21_4s                 # no
4330        bsr.l           srem_sinf                       # yes
4331        bra.b           _L21_6s
4332_L21_4s:
4333        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4334        bne.b           _L21_5s                 # no
4335        bsr.l           sop_sqnan                       # yes
4336        bra.b           _L21_6s
4337_L21_5s:
4338        bsr.l           srem_sdnrm                      # operand is a DENORM
4339_L21_6s:
4340
4341#
4342#       Result is now in FP0
4343#
4344        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4345        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4346        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4347        unlk            %a6
4348        rts
4349
4350        global          _fremd_
4351_fremd_:
4352        link            %a6,&-LOCAL_SIZE
4353
4354        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4355        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4356        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4357
4358        fmov.l          &0x0,%fpcr              # zero FPCR
4359
4360#
4361#       copy, convert, and tag input argument
4362#
4363        fmov.d          0x8(%a6),%fp0           # load dbl dst
4364        fmov.x          %fp0,FP_DST(%a6)
4365        lea             FP_DST(%a6),%a0
4366        bsr.l           tag                     # fetch operand type
4367        mov.b           %d0,DTAG(%a6)
4368
4369        fmov.d          0x10(%a6),%fp0          # load dbl src
4370        fmov.x          %fp0,FP_SRC(%a6)
4371        lea             FP_SRC(%a6),%a0
4372        bsr.l           tag                     # fetch operand type
4373        mov.b           %d0,STAG(%a6)
4374        mov.l           %d0,%d1
4375
4376        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4377
4378        clr.l           %d0
4379        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4380
4381        lea             FP_SRC(%a6),%a0         # pass ptr to src
4382        lea             FP_DST(%a6),%a1         # pass ptr to dst
4383
4384        tst.b           %d1
4385        bne.b           _L21_2d
4386        bsr.l           srem_snorm                      # operand is a NORM
4387        bra.b           _L21_6d
4388_L21_2d:
4389        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4390        bne.b           _L21_3d                 # no
4391        bsr.l           srem_szero                      # yes
4392        bra.b           _L21_6d
4393_L21_3d:
4394        cmpi.b          %d1,&INF                # is operand an INF?
4395        bne.b           _L21_4d                 # no
4396        bsr.l           srem_sinf                       # yes
4397        bra.b           _L21_6d
4398_L21_4d:
4399        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4400        bne.b           _L21_5d                 # no
4401        bsr.l           sop_sqnan                       # yes
4402        bra.b           _L21_6d
4403_L21_5d:
4404        bsr.l           srem_sdnrm                      # operand is a DENORM
4405_L21_6d:
4406
4407#
4408#       Result is now in FP0
4409#
4410        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4411        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4412        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4413        unlk            %a6
4414        rts
4415
4416        global          _fremx_
4417_fremx_:
4418        link            %a6,&-LOCAL_SIZE
4419
4420        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4421        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4422        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4423
4424        fmov.l          &0x0,%fpcr              # zero FPCR
4425
4426#
4427#       copy, convert, and tag input argument
4428#
4429        lea             FP_DST(%a6),%a0
4430        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext dst
4431        mov.l           0x8+0x4(%a6),0x4(%a0)
4432        mov.l           0x8+0x8(%a6),0x8(%a0)
4433        bsr.l           tag                     # fetch operand type
4434        mov.b           %d0,DTAG(%a6)
4435
4436        lea             FP_SRC(%a6),%a0
4437        mov.l           0x14+0x0(%a6),0x0(%a0)  # load ext src
4438        mov.l           0x14+0x4(%a6),0x4(%a0)
4439        mov.l           0x14+0x8(%a6),0x8(%a0)
4440        bsr.l           tag                     # fetch operand type
4441        mov.b           %d0,STAG(%a6)
4442        mov.l           %d0,%d1
4443
4444        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4445
4446        clr.l           %d0
4447        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4448
4449        lea             FP_SRC(%a6),%a0         # pass ptr to src
4450        lea             FP_DST(%a6),%a1         # pass ptr to dst
4451
4452        tst.b           %d1
4453        bne.b           _L21_2x
4454        bsr.l           srem_snorm                      # operand is a NORM
4455        bra.b           _L21_6x
4456_L21_2x:
4457        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4458        bne.b           _L21_3x                 # no
4459        bsr.l           srem_szero                      # yes
4460        bra.b           _L21_6x
4461_L21_3x:
4462        cmpi.b          %d1,&INF                # is operand an INF?
4463        bne.b           _L21_4x                 # no
4464        bsr.l           srem_sinf                       # yes
4465        bra.b           _L21_6x
4466_L21_4x:
4467        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4468        bne.b           _L21_5x                 # no
4469        bsr.l           sop_sqnan                       # yes
4470        bra.b           _L21_6x
4471_L21_5x:
4472        bsr.l           srem_sdnrm                      # operand is a DENORM
4473_L21_6x:
4474
4475#
4476#       Result is now in FP0
4477#
4478        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4479        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4480        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4481        unlk            %a6
4482        rts
4483
4484
4485#########################################################################
4486# DYADIC TEMPLATE                                                       #
4487#########################################################################
4488        global          _fmods_
4489_fmods_:
4490        link            %a6,&-LOCAL_SIZE
4491
4492        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4493        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4494        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4495
4496        fmov.l          &0x0,%fpcr              # zero FPCR
4497
4498#
4499#       copy, convert, and tag input argument
4500#
4501        fmov.s          0x8(%a6),%fp0           # load sgl dst
4502        fmov.x          %fp0,FP_DST(%a6)
4503        lea             FP_DST(%a6),%a0
4504        bsr.l           tag                     # fetch operand type
4505        mov.b           %d0,DTAG(%a6)
4506
4507        fmov.s          0xc(%a6),%fp0           # load sgl src
4508        fmov.x          %fp0,FP_SRC(%a6)
4509        lea             FP_SRC(%a6),%a0
4510        bsr.l           tag                     # fetch operand type
4511        mov.b           %d0,STAG(%a6)
4512        mov.l           %d0,%d1
4513
4514        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4515
4516        clr.l           %d0
4517        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4518
4519        lea             FP_SRC(%a6),%a0         # pass ptr to src
4520        lea             FP_DST(%a6),%a1         # pass ptr to dst
4521
4522        tst.b           %d1
4523        bne.b           _L22_2s
4524        bsr.l           smod_snorm                      # operand is a NORM
4525        bra.b           _L22_6s
4526_L22_2s:
4527        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4528        bne.b           _L22_3s                 # no
4529        bsr.l           smod_szero                      # yes
4530        bra.b           _L22_6s
4531_L22_3s:
4532        cmpi.b          %d1,&INF                # is operand an INF?
4533        bne.b           _L22_4s                 # no
4534        bsr.l           smod_sinf                       # yes
4535        bra.b           _L22_6s
4536_L22_4s:
4537        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4538        bne.b           _L22_5s                 # no
4539        bsr.l           sop_sqnan                       # yes
4540        bra.b           _L22_6s
4541_L22_5s:
4542        bsr.l           smod_sdnrm                      # operand is a DENORM
4543_L22_6s:
4544
4545#
4546#       Result is now in FP0
4547#
4548        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4549        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4550        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4551        unlk            %a6
4552        rts
4553
4554        global          _fmodd_
4555_fmodd_:
4556        link            %a6,&-LOCAL_SIZE
4557
4558        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4559        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4560        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4561
4562        fmov.l          &0x0,%fpcr              # zero FPCR
4563
4564#
4565#       copy, convert, and tag input argument
4566#
4567        fmov.d          0x8(%a6),%fp0           # load dbl dst
4568        fmov.x          %fp0,FP_DST(%a6)
4569        lea             FP_DST(%a6),%a0
4570        bsr.l           tag                     # fetch operand type
4571        mov.b           %d0,DTAG(%a6)
4572
4573        fmov.d          0x10(%a6),%fp0          # load dbl src
4574        fmov.x          %fp0,FP_SRC(%a6)
4575        lea             FP_SRC(%a6),%a0
4576        bsr.l           tag                     # fetch operand type
4577        mov.b           %d0,STAG(%a6)
4578        mov.l           %d0,%d1
4579
4580        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4581
4582        clr.l           %d0
4583        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4584
4585        lea             FP_SRC(%a6),%a0         # pass ptr to src
4586        lea             FP_DST(%a6),%a1         # pass ptr to dst
4587
4588        tst.b           %d1
4589        bne.b           _L22_2d
4590        bsr.l           smod_snorm                      # operand is a NORM
4591        bra.b           _L22_6d
4592_L22_2d:
4593        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4594        bne.b           _L22_3d                 # no
4595        bsr.l           smod_szero                      # yes
4596        bra.b           _L22_6d
4597_L22_3d:
4598        cmpi.b          %d1,&INF                # is operand an INF?
4599        bne.b           _L22_4d                 # no
4600        bsr.l           smod_sinf                       # yes
4601        bra.b           _L22_6d
4602_L22_4d:
4603        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4604        bne.b           _L22_5d                 # no
4605        bsr.l           sop_sqnan                       # yes
4606        bra.b           _L22_6d
4607_L22_5d:
4608        bsr.l           smod_sdnrm                      # operand is a DENORM
4609_L22_6d:
4610
4611#
4612#       Result is now in FP0
4613#
4614        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4615        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4616        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4617        unlk            %a6
4618        rts
4619
4620        global          _fmodx_
4621_fmodx_:
4622        link            %a6,&-LOCAL_SIZE
4623
4624        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4625        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4626        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4627
4628        fmov.l          &0x0,%fpcr              # zero FPCR
4629
4630#
4631#       copy, convert, and tag input argument
4632#
4633        lea             FP_DST(%a6),%a0
4634        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext dst
4635        mov.l           0x8+0x4(%a6),0x4(%a0)
4636        mov.l           0x8+0x8(%a6),0x8(%a0)
4637        bsr.l           tag                     # fetch operand type
4638        mov.b           %d0,DTAG(%a6)
4639
4640        lea             FP_SRC(%a6),%a0
4641        mov.l           0x14+0x0(%a6),0x0(%a0)  # load ext src
4642        mov.l           0x14+0x4(%a6),0x4(%a0)
4643        mov.l           0x14+0x8(%a6),0x8(%a0)
4644        bsr.l           tag                     # fetch operand type
4645        mov.b           %d0,STAG(%a6)
4646        mov.l           %d0,%d1
4647
4648        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4649
4650        clr.l           %d0
4651        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4652
4653        lea             FP_SRC(%a6),%a0         # pass ptr to src
4654        lea             FP_DST(%a6),%a1         # pass ptr to dst
4655
4656        tst.b           %d1
4657        bne.b           _L22_2x
4658        bsr.l           smod_snorm                      # operand is a NORM
4659        bra.b           _L22_6x
4660_L22_2x:
4661        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4662        bne.b           _L22_3x                 # no
4663        bsr.l           smod_szero                      # yes
4664        bra.b           _L22_6x
4665_L22_3x:
4666        cmpi.b          %d1,&INF                # is operand an INF?
4667        bne.b           _L22_4x                 # no
4668        bsr.l           smod_sinf                       # yes
4669        bra.b           _L22_6x
4670_L22_4x:
4671        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4672        bne.b           _L22_5x                 # no
4673        bsr.l           sop_sqnan                       # yes
4674        bra.b           _L22_6x
4675_L22_5x:
4676        bsr.l           smod_sdnrm                      # operand is a DENORM
4677_L22_6x:
4678
4679#
4680#       Result is now in FP0
4681#
4682        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4683        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4684        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4685        unlk            %a6
4686        rts
4687
4688
4689#########################################################################
4690# DYADIC TEMPLATE                                                       #
4691#########################################################################
4692        global          _fscales_
4693_fscales_:
4694        link            %a6,&-LOCAL_SIZE
4695
4696        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4697        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4698        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4699
4700        fmov.l          &0x0,%fpcr              # zero FPCR
4701
4702#
4703#       copy, convert, and tag input argument
4704#
4705        fmov.s          0x8(%a6),%fp0           # load sgl dst
4706        fmov.x          %fp0,FP_DST(%a6)
4707        lea             FP_DST(%a6),%a0
4708        bsr.l           tag                     # fetch operand type
4709        mov.b           %d0,DTAG(%a6)
4710
4711        fmov.s          0xc(%a6),%fp0           # load sgl src
4712        fmov.x          %fp0,FP_SRC(%a6)
4713        lea             FP_SRC(%a6),%a0
4714        bsr.l           tag                     # fetch operand type
4715        mov.b           %d0,STAG(%a6)
4716        mov.l           %d0,%d1
4717
4718        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4719
4720        clr.l           %d0
4721        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4722
4723        lea             FP_SRC(%a6),%a0         # pass ptr to src
4724        lea             FP_DST(%a6),%a1         # pass ptr to dst
4725
4726        tst.b           %d1
4727        bne.b           _L23_2s
4728        bsr.l           sscale_snorm                    # operand is a NORM
4729        bra.b           _L23_6s
4730_L23_2s:
4731        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4732        bne.b           _L23_3s                 # no
4733        bsr.l           sscale_szero                    # yes
4734        bra.b           _L23_6s
4735_L23_3s:
4736        cmpi.b          %d1,&INF                # is operand an INF?
4737        bne.b           _L23_4s                 # no
4738        bsr.l           sscale_sinf                     # yes
4739        bra.b           _L23_6s
4740_L23_4s:
4741        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4742        bne.b           _L23_5s                 # no
4743        bsr.l           sop_sqnan                       # yes
4744        bra.b           _L23_6s
4745_L23_5s:
4746        bsr.l           sscale_sdnrm                    # operand is a DENORM
4747_L23_6s:
4748
4749#
4750#       Result is now in FP0
4751#
4752        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4753        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4754        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4755        unlk            %a6
4756        rts
4757
4758        global          _fscaled_
4759_fscaled_:
4760        link            %a6,&-LOCAL_SIZE
4761
4762        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4763        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4764        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4765
4766        fmov.l          &0x0,%fpcr              # zero FPCR
4767
4768#
4769#       copy, convert, and tag input argument
4770#
4771        fmov.d          0x8(%a6),%fp0           # load dbl dst
4772        fmov.x          %fp0,FP_DST(%a6)
4773        lea             FP_DST(%a6),%a0
4774        bsr.l           tag                     # fetch operand type
4775        mov.b           %d0,DTAG(%a6)
4776
4777        fmov.d          0x10(%a6),%fp0          # load dbl src
4778        fmov.x          %fp0,FP_SRC(%a6)
4779        lea             FP_SRC(%a6),%a0
4780        bsr.l           tag                     # fetch operand type
4781        mov.b           %d0,STAG(%a6)
4782        mov.l           %d0,%d1
4783
4784        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4785
4786        clr.l           %d0
4787        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4788
4789        lea             FP_SRC(%a6),%a0         # pass ptr to src
4790        lea             FP_DST(%a6),%a1         # pass ptr to dst
4791
4792        tst.b           %d1
4793        bne.b           _L23_2d
4794        bsr.l           sscale_snorm                    # operand is a NORM
4795        bra.b           _L23_6d
4796_L23_2d:
4797        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4798        bne.b           _L23_3d                 # no
4799        bsr.l           sscale_szero                    # yes
4800        bra.b           _L23_6d
4801_L23_3d:
4802        cmpi.b          %d1,&INF                # is operand an INF?
4803        bne.b           _L23_4d                 # no
4804        bsr.l           sscale_sinf                     # yes
4805        bra.b           _L23_6d
4806_L23_4d:
4807        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4808        bne.b           _L23_5d                 # no
4809        bsr.l           sop_sqnan                       # yes
4810        bra.b           _L23_6d
4811_L23_5d:
4812        bsr.l           sscale_sdnrm                    # operand is a DENORM
4813_L23_6d:
4814
4815#
4816#       Result is now in FP0
4817#
4818        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4819        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4820        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4821        unlk            %a6
4822        rts
4823
4824        global          _fscalex_
4825_fscalex_:
4826        link            %a6,&-LOCAL_SIZE
4827
4828        movm.l          &0x0303,EXC_DREGS(%a6)  # save d0-d1/a0-a1
4829        fmovm.l         %fpcr,%fpsr,USER_FPCR(%a6) # save ctrl regs
4830        fmovm.x         &0xc0,EXC_FP0(%a6)      # save fp0/fp1
4831
4832        fmov.l          &0x0,%fpcr              # zero FPCR
4833
4834#
4835#       copy, convert, and tag input argument
4836#
4837        lea             FP_DST(%a6),%a0
4838        mov.l           0x8+0x0(%a6),0x0(%a0)   # load ext dst
4839        mov.l           0x8+0x4(%a6),0x4(%a0)
4840        mov.l           0x8+0x8(%a6),0x8(%a0)
4841        bsr.l           tag                     # fetch operand type
4842        mov.b           %d0,DTAG(%a6)
4843
4844        lea             FP_SRC(%a6),%a0
4845        mov.l           0x14+0x0(%a6),0x0(%a0)  # load ext src
4846        mov.l           0x14+0x4(%a6),0x4(%a0)
4847        mov.l           0x14+0x8(%a6),0x8(%a0)
4848        bsr.l           tag                     # fetch operand type
4849        mov.b           %d0,STAG(%a6)
4850        mov.l           %d0,%d1
4851
4852        andi.l          &0x00ff00ff,USER_FPSR(%a6)
4853
4854        clr.l           %d0
4855        mov.b           FPCR_MODE(%a6),%d0      # pass rnd mode,prec
4856
4857        lea             FP_SRC(%a6),%a0         # pass ptr to src
4858        lea             FP_DST(%a6),%a1         # pass ptr to dst
4859
4860        tst.b           %d1
4861        bne.b           _L23_2x
4862        bsr.l           sscale_snorm                    # operand is a NORM
4863        bra.b           _L23_6x
4864_L23_2x:
4865        cmpi.b          %d1,&ZERO               # is operand a ZERO?
4866        bne.b           _L23_3x                 # no
4867        bsr.l           sscale_szero                    # yes
4868        bra.b           _L23_6x
4869_L23_3x:
4870        cmpi.b          %d1,&INF                # is operand an INF?
4871        bne.b           _L23_4x                 # no
4872        bsr.l           sscale_sinf                     # yes
4873        bra.b           _L23_6x
4874_L23_4x:
4875        cmpi.b          %d1,&QNAN               # is operand a QNAN?
4876        bne.b           _L23_5x                 # no
4877        bsr.l           sop_sqnan                       # yes
4878        bra.b           _L23_6x
4879_L23_5x:
4880        bsr.l           sscale_sdnrm                    # operand is a DENORM
4881_L23_6x:
4882
4883#
4884#       Result is now in FP0
4885#
4886        movm.l          EXC_DREGS(%a6),&0x0303  # restore d0-d1/a0-a1
4887        fmovm.l         USER_FPCR(%a6),%fpcr,%fpsr # restore ctrl regs
4888        fmovm.x         EXC_FP1(%a6),&0x40      # restore fp1
4889        unlk            %a6
4890        rts
4891
4892
4893#########################################################################
4894# ssin():     computes the sine of a normalized input                   #
4895# ssind():    computes the sine of a denormalized input                 #
4896# scos():     computes the cosine of a normalized input                 #
4897# scosd():    computes the cosine of a denormalized input               #
4898# ssincos():  computes the sine and cosine of a normalized input        #
4899# ssincosd(): computes the sine and cosine of a denormalized input      #
4900#                                                                       #
4901# INPUT *************************************************************** #
4902#       a0 = pointer to extended precision input                        #
4903#       d0 = round precision,mode                                       #
4904#                                                                       #
4905# OUTPUT ************************************************************** #
4906#       fp0 = sin(X) or cos(X)                                          #
4907#                                                                       #
4908#    For ssincos(X):                                                    #
4909#       fp0 = sin(X)                                                    #
4910#       fp1 = cos(X)                                                    #
4911#                                                                       #
4912# ACCURACY and MONOTONICITY ******************************************* #
4913#       The returned result is within 1 ulp in 64 significant bit, i.e. #
4914#       within 0.5001 ulp to 53 bits if the result is subsequently      #
4915#       rounded to double precision. The result is provably monotonic   #
4916#       in double precision.                                            #
4917#                                                                       #
4918# ALGORITHM *********************************************************** #
4919#                                                                       #
4920#       SIN and COS:                                                    #
4921#       1. If SIN is invoked, set AdjN := 0; otherwise, set AdjN := 1.  #
4922#                                                                       #
4923#       2. If |X| >= 15Pi or |X| < 2**(-40), go to 7.                   #
4924#                                                                       #
4925#       3. Decompose X as X = N(Pi/2) + r where |r| <= Pi/4. Let        #
4926#               k = N mod 4, so in particular, k = 0,1,2,or 3.          #
4927#               Overwrite k by k := k + AdjN.                           #
4928#                                                                       #
4929#       4. If k is even, go to 6.                                       #
4930#                                                                       #
4931#       5. (k is odd) Set j := (k-1)/2, sgn := (-1)**j.                 #
4932#               Return sgn*cos(r) where cos(r) is approximated by an    #
4933#               even polynomial in r, 1 + r*r*(B1+s*(B2+ ... + s*B8)),  #
4934#               s = r*r.                                                #
4935#               Exit.                                                   #
4936#                                                                       #
4937#       6. (k is even) Set j := k/2, sgn := (-1)**j. Return sgn*sin(r)  #
4938#               where sin(r) is approximated by an odd polynomial in r  #
4939#               r + r*s*(A1+s*(A2+ ... + s*A7)),        s = r*r.        #
4940#               Exit.                                                   #
4941#                                                                       #
4942#       7. If |X| > 1, go to 9.                                         #
4943#                                                                       #
4944#       8. (|X|<2**(-40)) If SIN is invoked, return X;                  #
4945#               otherwise return 1.                                     #
4946#                                                                       #
4947#       9. Overwrite X by X := X rem 2Pi. Now that |X| <= Pi,           #
4948#               go back to 3.                                           #
4949#                                                                       #
4950#       SINCOS:                                                         #
4951#       1. If |X| >= 15Pi or |X| < 2**(-40), go to 6.                   #
4952#                                                                       #
4953#       2. Decompose X as X = N(Pi/2) + r where |r| <= Pi/4. Let        #
4954#               k = N mod 4, so in particular, k = 0,1,2,or 3.          #
4955#                                                                       #
4956#       3. If k is even, go to 5.                                       #
4957#                                                                       #
4958#       4. (k is odd) Set j1 := (k-1)/2, j2 := j1 (EOR) (k mod 2), ie.  #
4959#               j1 exclusive or with the l.s.b. of k.                   #
4960#               sgn1 := (-1)**j1, sgn2 := (-1)**j2.                     #
4961#               SIN(X) = sgn1 * cos(r) and COS(X) = sgn2*sin(r) where   #
4962#               sin(r) and cos(r) are computed as odd and even          #
4963#               polynomials in r, respectively. Exit                    #
4964#                                                                       #
4965#       5. (k is even) Set j1 := k/2, sgn1 := (-1)**j1.                 #
4966#               SIN(X) = sgn1 * sin(r) and COS(X) = sgn1*cos(r) where   #
4967#               sin(r) and cos(r) are computed as odd and even          #
4968#               polynomials in r, respectively. Exit                    #
4969#                                                                       #
4970#       6. If |X| > 1, go to 8.                                         #
4971#                                                                       #
4972#       7. (|X|<2**(-40)) SIN(X) = X and COS(X) = 1. Exit.              #
4973#                                                                       #
4974#       8. Overwrite X by X := X rem 2Pi. Now that |X| <= Pi,           #
4975#               go back to 2.                                           #
4976#                                                                       #
4977#########################################################################
4978
4979SINA7:  long            0xBD6AAA77,0xCCC994F5
4980SINA6:  long            0x3DE61209,0x7AAE8DA1
4981SINA5:  long            0xBE5AE645,0x2A118AE4
4982SINA4:  long            0x3EC71DE3,0xA5341531
4983SINA3:  long            0xBF2A01A0,0x1A018B59,0x00000000,0x00000000
4984SINA2:  long            0x3FF80000,0x88888888,0x888859AF,0x00000000
4985SINA1:  long            0xBFFC0000,0xAAAAAAAA,0xAAAAAA99,0x00000000
4986
4987COSB8:  long            0x3D2AC4D0,0xD6011EE3
4988COSB7:  long            0xBDA9396F,0x9F45AC19
4989COSB6:  long            0x3E21EED9,0x0612C972
4990COSB5:  long            0xBE927E4F,0xB79D9FCF
4991COSB4:  long            0x3EFA01A0,0x1A01D423,0x00000000,0x00000000
4992COSB3:  long            0xBFF50000,0xB60B60B6,0x0B61D438,0x00000000
4993COSB2:  long            0x3FFA0000,0xAAAAAAAA,0xAAAAAB5E
4994COSB1:  long            0xBF000000
4995
4996        set             INARG,FP_SCR0
4997
4998        set             X,FP_SCR0
4999#       set             XDCARE,X+2
5000        set             XFRAC,X+4
5001
5002        set             RPRIME,FP_SCR0
5003        set             SPRIME,FP_SCR1
5004
5005        set             POSNEG1,L_SCR1
5006        set             TWOTO63,L_SCR1
5007
5008        set             ENDFLAG,L_SCR2
5009        set             INT,L_SCR2
5010
5011        set             ADJN,L_SCR3
5012
5013############################################
5014        global          ssin
5015ssin:
5016        mov.l           &0,ADJN(%a6)            # yes; SET ADJN TO 0
5017        bra.b           SINBGN
5018
5019############################################
5020        global          scos
5021scos:
5022        mov.l           &1,ADJN(%a6)            # yes; SET ADJN TO 1
5023
5024############################################
5025SINBGN:
5026#--SAVE FPCR, FP1. CHECK IF |X| IS TOO SMALL OR LARGE
5027
5028        fmov.x          (%a0),%fp0              # LOAD INPUT
5029        fmov.x          %fp0,X(%a6)             # save input at X
5030
5031# "COMPACTIFY" X
5032        mov.l           (%a0),%d1               # put exp in hi word
5033        mov.w           4(%a0),%d1              # fetch hi(man)
5034        and.l           &0x7FFFFFFF,%d1         # strip sign
5035
5036        cmpi.l          %d1,&0x3FD78000         # is |X| >= 2**(-40)?
5037        bge.b           SOK1                    # no
5038        bra.w           SINSM                   # yes; input is very small
5039
5040SOK1:
5041        cmp.l           %d1,&0x4004BC7E         # is |X| < 15 PI?
5042        blt.b           SINMAIN                 # no
5043        bra.w           SREDUCEX                # yes; input is very large
5044
5045#--THIS IS THE USUAL CASE, |X| <= 15 PI.
5046#--THE ARGUMENT REDUCTION IS DONE BY TABLE LOOK UP.
5047SINMAIN:
5048        fmov.x          %fp0,%fp1
5049        fmul.d          TWOBYPI(%pc),%fp1       # X*2/PI
5050
5051        lea             PITBL+0x200(%pc),%a1    # TABLE OF N*PI/2, N = -32,...,32
5052
5053        fmov.l          %fp1,INT(%a6)           # CONVERT TO INTEGER
5054
5055        mov.l           INT(%a6),%d1            # make a copy of N
5056        asl.l           &4,%d1                  # N *= 16
5057        add.l           %d1,%a1                 # tbl_addr = a1 + (N*16)
5058
5059# A1 IS THE ADDRESS OF N*PIBY2
5060# ...WHICH IS IN TWO PIECES Y1 & Y2
5061        fsub.x          (%a1)+,%fp0             # X-Y1
5062        fsub.s          (%a1),%fp0              # fp0 = R = (X-Y1)-Y2
5063
5064SINCONT:
5065#--continuation from REDUCEX
5066
5067#--GET N+ADJN AND SEE IF SIN(R) OR COS(R) IS NEEDED
5068        mov.l           INT(%a6),%d1
5069        add.l           ADJN(%a6),%d1           # SEE IF D0 IS ODD OR EVEN
5070        ror.l           &1,%d1                  # D0 WAS ODD IFF D0 IS NEGATIVE
5071        cmp.l           %d1,&0
5072        blt.w           COSPOLY
5073
5074#--LET J BE THE LEAST SIG. BIT OF D0, LET SGN := (-1)**J.
5075#--THEN WE RETURN       SGN*SIN(R). SGN*SIN(R) IS COMPUTED BY
5076#--R' + R'*S*(A1 + S(A2 + S(A3 + S(A4 + ... + SA7)))), WHERE
5077#--R' = SGN*R, S=R*R. THIS CAN BE REWRITTEN AS
5078#--R' + R'*S*( [A1+T(A3+T(A5+TA7))] + [S(A2+T(A4+TA6))])
5079#--WHERE T=S*S.
5080#--NOTE THAT A3 THROUGH A7 ARE STORED IN DOUBLE PRECISION
5081#--WHILE A1 AND A2 ARE IN DOUBLE-EXTENDED FORMAT.
5082SINPOLY:
5083        fmovm.x         &0x0c,-(%sp)            # save fp2/fp3
5084
5085        fmov.x          %fp0,X(%a6)             # X IS R
5086        fmul.x          %fp0,%fp0               # FP0 IS S
5087
5088        fmov.d          SINA7(%pc),%fp3
5089        fmov.d          SINA6(%pc),%fp2
5090
5091        fmov.x          %fp0,%fp1
5092        fmul.x          %fp1,%fp1               # FP1 IS T
5093
5094        ror.l           &1,%d1
5095        and.l           &0x80000000,%d1
5096# ...LEAST SIG. BIT OF D0 IN SIGN POSITION
5097        eor.l           %d1,X(%a6)              # X IS NOW R'= SGN*R
5098
5099        fmul.x          %fp1,%fp3               # TA7
5100        fmul.x          %fp1,%fp2               # TA6
5101
5102        fadd.d          SINA5(%pc),%fp3         # A5+TA7
5103        fadd.d          SINA4(%pc),%fp2         # A4+TA6
5104
5105        fmul.x          %fp1,%fp3               # T(A5+TA7)
5106        fmul.x          %fp1,%fp2               # T(A4+TA6)
5107
5108        fadd.d          SINA3(%pc),%fp3         # A3+T(A5+TA7)
5109        fadd.x          SINA2(%pc),%fp2         # A2+T(A4+TA6)
5110
5111        fmul.x          %fp3,%fp1               # T(A3+T(A5+TA7))
5112
5113        fmul.x          %fp0,%fp2               # S(A2+T(A4+TA6))
5114        fadd.x          SINA1(%pc),%fp1         # A1+T(A3+T(A5+TA7))
5115        fmul.x          X(%a6),%fp0             # R'*S
5116
5117        fadd.x          %fp2,%fp1               # [A1+T(A3+T(A5+TA7))]+[S(A2+T(A4+TA6))]
5118
5119        fmul.x          %fp1,%fp0               # SIN(R')-R'
5120
5121        fmovm.x         (%sp)+,&0x30            # restore fp2/fp3
5122
5123        fmov.l          %d0,%fpcr               # restore users round mode,prec
5124        fadd.x          X(%a6),%fp0             # last inst - possible exception set
5125        bra             t_inx2
5126
5127#--LET J BE THE LEAST SIG. BIT OF D0, LET SGN := (-1)**J.
5128#--THEN WE RETURN       SGN*COS(R). SGN*COS(R) IS COMPUTED BY
5129#--SGN + S'*(B1 + S(B2 + S(B3 + S(B4 + ... + SB8)))), WHERE
5130#--S=R*R AND S'=SGN*S. THIS CAN BE REWRITTEN AS
5131#--SGN + S'*([B1+T(B3+T(B5+TB7))] + [S(B2+T(B4+T(B6+TB8)))])
5132#--WHERE T=S*S.
5133#--NOTE THAT B4 THROUGH B8 ARE STORED IN DOUBLE PRECISION
5134#--WHILE B2 AND B3 ARE IN DOUBLE-EXTENDED FORMAT, B1 IS -1/2
5135#--AND IS THEREFORE STORED AS SINGLE PRECISION.
5136COSPOLY:
5137        fmovm.x         &0x0c,-(%sp)            # save fp2/fp3
5138
5139        fmul.x          %fp0,%fp0               # FP0 IS S
5140
5141        fmov.d          COSB8(%pc),%fp2
5142        fmov.d          COSB7(%pc),%fp3
5143
5144        fmov.x          %fp0,%fp1
5145        fmul.x          %fp1,%fp1               # FP1 IS T
5146
5147        fmov.x          %fp0,X(%a6)             # X IS S
5148        ror.l           &1,%d1
5149        and.l           &0x80000000,%d1
5150# ...LEAST SIG. BIT OF D0 IN SIGN POSITION
5151
5152        fmul.x          %fp1,%fp2               # TB8
5153
5154        eor.l           %d1,X(%a6)              # X IS NOW S'= SGN*S
5155        and.l           &0x80000000,%d1
5156
5157        fmul.x          %fp1,%fp3               # TB7
5158
5159        or.l            &0x3F800000,%d1         # D0 IS SGN IN SINGLE
5160        mov.l           %d1,POSNEG1(%a6)
5161
5162        fadd.d          COSB6(%pc),%fp2         # B6+TB8
5163        fadd.d          COSB5(%pc),%fp3         # B5+TB7
5164
5165        fmul.x          %fp1,%fp2               # T(B6+TB8)
5166        fmul.x          %fp1,%fp3               # T(B5+TB7)
5167
5168        fadd.d          COSB4(%pc),%fp2         # B4+T(B6+TB8)
5169        fadd.x          COSB3(%pc),%fp3         # B3+T(B5+TB7)
5170
5171        fmul.x          %fp1,%fp2               # T(B4+T(B6+TB8))
5172        fmul.x          %fp3,%fp1               # T(B3+T(B5+TB7))
5173
5174        fadd.x          COSB2(%pc),%fp2         # B2+T(B4+T(B6+TB8))
5175        fadd.s          COSB1(%pc),%fp1         # B1+T(B3+T(B5+TB7))
5176
5177        fmul.x          %fp2,%fp0               # S(B2+T(B4+T(B6+TB8)))
5178
5179        fadd.x          %fp1,%fp0
5180
5181        fmul.x          X(%a6),%fp0
5182
5183        fmovm.x         (%sp)+,&0x30            # restore fp2/fp3
5184
5185        fmov.l          %d0,%fpcr               # restore users round mode,prec
5186        fadd.s          POSNEG1(%a6),%fp0       # last inst - possible exception set
5187        bra             t_inx2
5188
5189##############################################
5190
5191# SINe: Big OR Small?
5192#--IF |X| > 15PI, WE USE THE GENERAL ARGUMENT REDUCTION.
5193#--IF |X| < 2**(-40), RETURN X OR 1.
5194SINBORS:
5195        cmp.l           %d1,&0x3FFF8000
5196        bgt.l           SREDUCEX
5197
5198SINSM:
5199        mov.l           ADJN(%a6),%d1
5200        cmp.l           %d1,&0
5201        bgt.b           COSTINY
5202
5203# here, the operation may underflow iff the precision is sgl or dbl.
5204# extended denorms are handled through another entry point.
5205SINTINY:
5206#       mov.w           &0x0000,XDCARE(%a6)     # JUST IN CASE
5207
5208        fmov.l          %d0,%fpcr               # restore users round mode,prec
5209        mov.b           &FMOV_OP,%d1            # last inst is MOVE
5210        fmov.x          X(%a6),%fp0             # last inst - possible exception set
5211        bra             t_catch
5212
5213COSTINY:
5214        fmov.s          &0x3F800000,%fp0        # fp0 = 1.0
5215        fmov.l          %d0,%fpcr               # restore users round mode,prec
5216        fadd.s          &0x80800000,%fp0        # last inst - possible exception set
5217        bra             t_pinx2
5218
5219################################################
5220        global          ssind
5221#--SIN(X) = X FOR DENORMALIZED X
5222ssind:
5223        bra             t_extdnrm
5224
5225############################################
5226        global          scosd
5227#--COS(X) = 1 FOR DENORMALIZED X
5228scosd:
5229        fmov.s          &0x3F800000,%fp0        # fp0 = 1.0
5230        bra             t_pinx2
5231
5232##################################################
5233
5234        global          ssincos
5235ssincos:
5236#--SET ADJN TO 4
5237        mov.l           &4,ADJN(%a6)
5238
5239        fmov.x          (%a0),%fp0              # LOAD INPUT
5240        fmov.x          %fp0,X(%a6)
5241
5242        mov.l           (%a0),%d1
5243        mov.w           4(%a0),%d1
5244        and.l           &0x7FFFFFFF,%d1         # COMPACTIFY X
5245
5246        cmp.l           %d1,&0x3FD78000         # |X| >= 2**(-40)?
5247        bge.b           SCOK1
5248        bra.w           SCSM
5249
5250SCOK1:
5251        cmp.l           %d1,&0x4004BC7E         # |X| < 15 PI?
5252        blt.b           SCMAIN
5253        bra.w           SREDUCEX
5254
5255
5256#--THIS IS THE USUAL CASE, |X| <= 15 PI.
5257#--THE ARGUMENT REDUCTION IS DONE BY TABLE LOOK UP.
5258SCMAIN:
5259        fmov.x          %fp0,%fp1
5260
5261        fmul.d          TWOBYPI(%pc),%fp1       # X*2/PI
5262
5263        lea             PITBL+0x200(%pc),%a1    # TABLE OF N*PI/2, N = -32,...,32
5264
5265        fmov.l          %fp1,INT(%a6)           # CONVERT TO INTEGER
5266
5267        mov.l           INT(%a6),%d1
5268        asl.l           &4,%d1
5269        add.l           %d1,%a1                 # ADDRESS OF N*PIBY2, IN Y1, Y2
5270
5271        fsub.x          (%a1)+,%fp0             # X-Y1
5272        fsub.s          (%a1),%fp0              # FP0 IS R = (X-Y1)-Y2
5273
5274SCCONT:
5275#--continuation point from REDUCEX
5276
5277        mov.l           INT(%a6),%d1
5278        ror.l           &1,%d1
5279        cmp.l           %d1,&0                  # D0 < 0 IFF N IS ODD
5280        bge.w           NEVEN
5281
5282SNODD:
5283#--REGISTERS SAVED SO FAR: D0, A0, FP2.
5284        fmovm.x         &0x04,-(%sp)            # save fp2
5285
5286        fmov.x          %fp0,RPRIME(%a6)
5287        fmul.x          %fp0,%fp0               # FP0 IS S = R*R
5288        fmov.d          SINA7(%pc),%fp1         # A7
5289        fmov.d          COSB8(%pc),%fp2         # B8
5290        fmul.x          %fp0,%fp1               # SA7
5291        fmul.x          %fp0,%fp2               # SB8
5292
5293        mov.l           %d2,-(%sp)
5294        mov.l           %d1,%d2
5295        ror.l           &1,%d2
5296        and.l           &0x80000000,%d2
5297        eor.l           %d1,%d2
5298        and.l           &0x80000000,%d2
5299
5300        fadd.d          SINA6(%pc),%fp1         # A6+SA7
5301        fadd.d          COSB7(%pc),%fp2         # B7+SB8
5302
5303        fmul.x          %fp0,%fp1               # S(A6+SA7)
5304        eor.l           %d2,RPRIME(%a6)
5305        mov.l           (%sp)+,%d2
5306        fmul.x          %fp0,%fp2               # S(B7+SB8)
5307        ror.l           &1,%d1
5308        and.l           &0x80000000,%d1
5309        mov.l           &0x3F800000,POSNEG1(%a6)
5310        eor.l           %d1,POSNEG1(%a6)
5311
5312        fadd.d          SINA5(%pc),%fp1         # A5+S(A6+SA7)
5313        fadd.d          COSB6(%pc),%fp2         # B6+S(B7+SB8)
5314
5315        fmul.x          %fp0,%fp1               # S(A5+S(A6+SA7))
5316        fmul.x          %fp0,%fp2               # S(B6+S(B7+SB8))
5317        fmov.x          %fp0,SPRIME(%a6)
5318
5319        fadd.d          SINA4(%pc),%fp1         # A4+S(A5+S(A6+SA7))
5320        eor.l           %d1,SPRIME(%a6)
5321        fadd.d          COSB5(%pc),%fp2         # B5+S(B6+S(B7+SB8))
5322
5323        fmul.x          %fp0,%fp1               # S(A4+...)
5324        fmul.x          %fp0,%fp2               # S(B5+...)
5325
5326        fadd.d          SINA3(%pc),%fp1         # A3+S(A4+...)
5327        fadd.d          COSB4(%pc),%fp2         # B4+S(B5+...)
5328
5329        fmul.x          %fp0,%fp1               # S(A3+...)
5330        fmul.x          %fp0,%fp2               # S(B4+...)
5331
5332        fadd.x          SINA2(%pc),%fp1         # A2+S(A3+...)
5333        fadd.x          COSB3(%pc),%fp2         # B3+S(B4+...)
5334
5335        fmul.x          %fp0,%fp1               # S(A2+...)
5336        fmul.x          %fp0,%fp2               # S(B3+...)
5337
5338        fadd.x          SINA1(%pc),%fp1         # A1+S(A2+...)
5339        fadd.x          COSB2(%pc),%fp2         # B2+S(B3+...)
5340
5341        fmul.x          %fp0,%fp1               # S(A1+...)
5342        fmul.x          %fp2,%fp0               # S(B2+...)
5343
5344        fmul.x          RPRIME(%a6),%fp1        # R'S(A1+...)
5345        fadd.s          COSB1(%pc),%fp0         # B1+S(B2...)
5346        fmul.x          SPRIME(%a6),%fp0        # S'(B1+S(B2+...))
5347
5348        fmovm.x         (%sp)+,&0x20            # restore fp2
5349
5350        fmov.l          %d0,%fpcr
5351        fadd.x          RPRIME(%a6),%fp1        # COS(X)
5352        bsr             sto_cos                 # store cosine result
5353        fadd.s          POSNEG1(%a6),%fp0       # SIN(X)
5354        bra             t_inx2
5355
5356NEVEN:
5357#--REGISTERS SAVED SO FAR: FP2.
5358        fmovm.x         &0x04,-(%sp)            # save fp2
5359
5360        fmov.x          %fp0,RPRIME(%a6)
5361        fmul.x          %fp0,%fp0               # FP0 IS S = R*R
5362
5363        fmov.d          COSB8(%pc),%fp1         # B8
5364        fmov.d          SINA7(%pc),%fp2         # A7
5365
5366        fmul.x          %fp0,%fp1               # SB8
5367        fmov.x          %fp0,SPRIME(%a6)
5368        fmul.x          %fp0,%fp2               # SA7
5369
5370        ror.l           &1,%d1
5371        and.l           &0x80000000,%d1
5372
5373        fadd.d          COSB7(%pc),%fp1         # B7+SB8
5374        fadd.d          SINA6(%pc),%fp2         # A6+SA7
5375
5376        eor.l           %d1,RPRIME(%a6)
5377        eor.l           %d1,SPRIME(%a6)
5378
5379        fmul.x          %fp0,%fp1               # S(B7+SB8)
5380
5381        or.l            &0x3F800000,%d1
5382        mov.l           %d1,POSNEG1(%a6)
5383
5384        fmul.x          %fp0,%fp2               # S(A6+SA7)
5385
5386        fadd.d          COSB6(%pc),%fp1         # B6+S(B7+SB8)
5387        fadd.d          SINA5(%pc),%fp2         # A5+S(A6+SA7)
5388
5389        fmul.x          %fp0,%fp1               # S(B6+S(B7+SB8))
5390        fmul.x          %fp0,%fp2               # S(A5+S(A6+SA7))
5391
5392        fadd.d          COSB5(%pc),%fp1         # B5+S(B6+S(B7+SB8))
5393        fadd.d          SINA4(%pc),%fp2         # A4+S(A5+S(A6+SA7))
5394
5395        fmul.x          %fp0,%fp1               # S(B5+...)
5396        fmul.x          %fp0,%fp2               # S(A4+...)
5397
5398        fadd.d          COSB4(%pc),%fp1         # B4+S(B5+...)
5399        fadd.d          SINA3(%pc),%fp2         # A3+S(A4+...)
5400
5401        fmul.x          %fp0,%fp1               # S(B4+...)
5402        fmul.x          %fp0,%fp2               # S(A3+...)
5403
5404        fadd.x          COSB3(%pc),%fp1         # B3+S(B4+...)
5405        fadd.x          SINA2(%pc),%fp2         # A2+S(A3+...)
5406
5407        fmul.x          %fp0,%fp1               # S(B3+...)
5408        fmul.x          %fp0,%fp2               # S(A2+...)
5409
5410        fadd.x          COSB2(%pc),%fp1         # B2+S(B3+...)
5411        fadd.x          SINA1(%pc),%fp2         # A1+S(A2+...)
5412
5413        fmul.x          %fp0,%fp1               # S(B2+...)
5414        fmul.x          %fp2,%fp0               # s(a1+...)
5415
5416
5417        fadd.s          COSB1(%pc),%fp1         # B1+S(B2...)
5418        fmul.x          RPRIME(%a6),%fp0        # R'S(A1+...)
5419        fmul.x          SPRIME(%a6),%fp1        # S'(B1+S(B2+...))
5420
5421        fmovm.x         (%sp)+,&0x20            # restore fp2
5422
5423        fmov.l          %d0,%fpcr
5424        fadd.s          POSNEG1(%a6),%fp1       # COS(X)
5425        bsr             sto_cos                 # store cosine result
5426        fadd.x          RPRIME(%a6),%fp0        # SIN(X)
5427        bra             t_inx2
5428
5429################################################
5430
5431SCBORS:
5432        cmp.l           %d1,&0x3FFF8000
5433        bgt.w           SREDUCEX
5434
5435################################################
5436
5437SCSM:
5438#       mov.w           &0x0000,XDCARE(%a6)
5439        fmov.s          &0x3F800000,%fp1
5440
5441        fmov.l          %d0,%fpcr
5442        fsub.s          &0x00800000,%fp1
5443        bsr             sto_cos                 # store cosine result
5444        fmov.l          %fpcr,%d0               # d0 must have fpcr,too
5445        mov.b           &FMOV_OP,%d1            # last inst is MOVE
5446        fmov.x          X(%a6),%fp0
5447        bra             t_catch
5448
5449##############################################
5450
5451        global          ssincosd
5452#--SIN AND COS OF X FOR DENORMALIZED X
5453ssincosd:
5454        mov.l           %d0,-(%sp)              # save d0
5455        fmov.s          &0x3F800000,%fp1
5456        bsr             sto_cos                 # store cosine result
5457        mov.l           (%sp)+,%d0              # restore d0
5458        bra             t_extdnrm
5459
5460############################################
5461
5462#--WHEN REDUCEX IS USED, THE CODE WILL INEVITABLY BE SLOW.
5463#--THIS REDUCTION METHOD, HOWEVER, IS MUCH FASTER THAN USING
5464#--THE REMAINDER INSTRUCTION WHICH IS NOW IN SOFTWARE.
5465SREDUCEX:
5466        fmovm.x         &0x3c,-(%sp)            # save {fp2-fp5}
5467        mov.l           %d2,-(%sp)              # save d2
5468        fmov.s          &0x00000000,%fp1        # fp1 = 0
5469
5470#--If compact form of abs(arg) in d0=$7ffeffff, argument is so large that
5471#--there is a danger of unwanted overflow in first LOOP iteration.  In this
5472#--case, reduce argument by one remainder step to make subsequent reduction
5473#--safe.
5474        cmp.l           %d1,&0x7ffeffff         # is arg dangerously large?
5475        bne.b           SLOOP                   # no
5476
5477# yes; create 2**16383*PI/2
5478        mov.w           &0x7ffe,FP_SCR0_EX(%a6)
5479        mov.l           &0xc90fdaa2,FP_SCR0_HI(%a6)
5480        clr.l           FP_SCR0_LO(%a6)
5481
5482# create low half of 2**16383*PI/2 at FP_SCR1
5483        mov.w           &0x7fdc,FP_SCR1_EX(%a6)
5484        mov.l           &0x85a308d3,FP_SCR1_HI(%a6)
5485        clr.l           FP_SCR1_LO(%a6)
5486
5487        ftest.x         %fp0                    # test sign of argument
5488        fblt.w          sred_neg
5489
5490        or.b            &0x80,FP_SCR0_EX(%a6)   # positive arg
5491        or.b            &0x80,FP_SCR1_EX(%a6)
5492sred_neg:
5493        fadd.x          FP_SCR0(%a6),%fp0       # high part of reduction is exact
5494        fmov.x          %fp0,%fp1               # save high result in fp1
5495        fadd.x          FP_SCR1(%a6),%fp0       # low part of reduction
5496        fsub.x          %fp0,%fp1               # determine low component of result
5497        fadd.x          FP_SCR1(%a6),%fp1       # fp0/fp1 are reduced argument.
5498
5499#--ON ENTRY, FP0 IS X, ON RETURN, FP0 IS X REM PI/2, |X| <= PI/4.
5500#--integer quotient will be stored in N
5501#--Intermeditate remainder is 66-bit long; (R,r) in (FP0,FP1)
5502SLOOP:
5503        fmov.x          %fp0,INARG(%a6)         # +-2**K * F, 1 <= F < 2
5504        mov.w           INARG(%a6),%d1
5505        mov.l           %d1,%a1                 # save a copy of D0
5506        and.l           &0x00007FFF,%d1
5507        sub.l           &0x00003FFF,%d1         # d0 = K
5508        cmp.l           %d1,&28
5509        ble.b           SLASTLOOP
5510SCONTLOOP:
5511        sub.l           &27,%d1                 # d0 = L := K-27
5512        mov.b           &0,ENDFLAG(%a6)
5513        bra.b           SWORK
5514SLASTLOOP:
5515        clr.l           %d1                     # d0 = L := 0
5516        mov.b           &1,ENDFLAG(%a6)
5517
5518SWORK:
5519#--FIND THE REMAINDER OF (R,r) W.R.T.   2**L * (PI/2). L IS SO CHOSEN
5520#--THAT INT( X * (2/