home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / libsrc87 / _cmpdf2.s < prev    next >
Encoding:
Text File  |  1993-07-30  |  3.1 KB  |  185 lines

  1. | double floating point compare routine
  2. |
  3. | written by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  4. | Based on a 68k floating point packet from Kai-Uwe Bloem, itself based
  5. | on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  6. | Revision 2.0: olaf 12-92.
  7. |
  8.  
  9.     .text
  10.     .even
  11.     .globl    ___eqdf2, ___nedf2
  12.     .globl    ___gtdf2, ___ledf2
  13.     .globl    ___gedf2, ___ltdf2
  14.     .globl    __cmpdf2, ___cmpdf2
  15.     
  16. __cmpdf2:
  17. ___cmpdf2:
  18. ___eqdf2:
  19. ___nedf2:
  20.     moveml    sp@(4),d0-d1/a0-a1        | get numbers to compare with
  21.     tstl    d0        | check sign bit
  22.     bpl    1f
  23.     negl    d1        | negate
  24.     negxl    d0
  25.     bchg    #31,d0        | toggle sign bit
  26.  
  27. 1:    exg    a0,d0
  28.     exg    a1,d1
  29.     tstl    d0        | check sign bit
  30.     bpl    2f
  31.     negl    d1        | negate
  32.     negxl    d0
  33.     bchg    #31,d0        | toggle sign bit
  34.  
  35. 2:    cmpl    d1,a1
  36.     bne    4f
  37.     cmpl    d0,a0
  38.     bne    4f
  39.     bclr    #31,d0
  40.     cmpl    #0x7ff00000,d0        | NaN is not equal NaN !
  41.     bgt    4f
  42.     blt    3f
  43.     tstl    d1
  44.     bne    4f
  45. 3:    clrl    d0
  46.     rts
  47.  
  48. 4:    moveql    #1,d0
  49.     rts
  50.  
  51. ___gtdf2:
  52.     moveml    sp@(4),d0-d1/a0-a1        | get numbers to compare with
  53.     tstl    d0        | check sign bit
  54.     bpl    1f
  55.     negl    d1        | negate
  56.     negxl    d0
  57.     bchg    #31,d0        | toggle sign bit
  58.  
  59. 1:    exg    a0,d0
  60.     exg    a1,d1
  61.     tstl    d0        | check sign bit
  62.     bpl    2f
  63.     negl    d1        | negate
  64.     negxl    d0
  65.     bchg    #31,d0        | toggle sign bit
  66.  
  67. 2:    exg    a0,d0
  68.     exg    a1,d1
  69.     cmpl    a0,d0
  70.     bgt    4f        | d0 > a0 Test if NaN (should be false!)
  71.     blt    3f        | 
  72.     cmpl    a1,d1
  73.     bhi    4f
  74. 3:    clrl    d0        | Test is false.
  75.     rts
  76. 4:    bclr    #31,d0        
  77.     cmpl    #0x7ff00000,d0    | First operand == NaN =?
  78.     bgt    3b
  79.     blt    5f        | It is finite!
  80.     tstl    d1
  81.     bne    3b        | It *is* a NaN
  82. 5:    moveql    #1,d0        | Test True
  83.     rts
  84.  
  85. ___ledf2:
  86.     moveml    sp@(4),d0-d1/a0-a1        | get numbers to compare with
  87.     tstl    d0        | check sign bit
  88.     bpl    1f
  89.     negl    d1        | negate
  90.     negxl    d0
  91.     bchg    #31,d0        | toggle sign bit
  92.  
  93. 1:    exg    a0,d0
  94.     exg    a1,d1
  95.     tstl    d0        | check sign bit
  96.     bpl    2f
  97.     negl    d1        | negate
  98.     negxl    d0
  99.     bchg    #31,d0        | toggle sign bit
  100.  
  101. 2:    cmpl    d0,a0
  102.     blt    4f
  103.     bgt    3f
  104.     cmpl    d1,a1
  105.     bls    4f            | <= !
  106. 3:    moveql    #1,d0        | Test is false
  107.     rts
  108. 4:    bclr    #31,d0        
  109.     cmpl    #0x7ff00000,d0    | First operand == NaN =?
  110.     bgt    3b
  111.     blt    5f        | It is finite!
  112.     tstl    d1
  113.     bne    3b        | It *is* a NaN
  114. 5:    clrl    d0        | Test true
  115.     rts
  116.  
  117. ___gedf2:
  118.     moveml    sp@(4),d0-d1/a0-a1        | get numbers to compare with
  119.     tstl    d0        | check sign bit
  120.     bpl    1f
  121.     negl    d1        | negate
  122.     negxl    d0
  123.     bchg    #31,d0        | toggle sign bit
  124.  
  125. 1:    exg    a0,d0
  126.     exg    a1,d1
  127.     tstl    d0        | check sign bit
  128.     bpl    2f
  129.     negl    d1        | negate
  130.     negxl    d0
  131.     bchg    #31,d0        | toggle sign bit
  132.  
  133. 2:    exg    a0,d0
  134.     exg    a1,d1
  135.     cmpl    a0,d0
  136.     bgt    4f
  137.     blt    3f
  138.     cmpl    a1,d1
  139.     beq    4f        | >= !
  140.     bhi    4f
  141. 3:    moveql    #-1,d0        | False
  142.     rts
  143. 4:    bclr    #31,d0        
  144.     cmpl    #0x7ff00000,d0    | First operand == NaN =?
  145.     bgt    3b
  146.     blt    5f        | It is finite!
  147.     tstl    d1
  148.     bne    3b        | It *is* a NaN
  149. 5:    clrl    d0        | Test True
  150.     rts
  151.  
  152. ___ltdf2:
  153.     moveml    sp@(4),d0-d1/a0-a1        | get numbers to compare with
  154.     tstl    d0        | check sign bit
  155.     bpl    1f
  156.     negl    d1        | negate
  157.     negxl    d0
  158.     bchg    #31,d0        | toggle sign bit
  159.  
  160. 1:    exg    a0,d0
  161.     exg    a1,d1
  162.     tstl    d0        | check sign bit
  163.     bpl    2f
  164.     negl    d1        | negate
  165.     negxl    d0
  166.     bchg    #31,d0        | toggle sign bit
  167.  
  168. 2:    cmpl    d0,a0
  169.     blt    4f
  170.     bgt    3f
  171.     cmpl    d1,a1
  172.     beq    3f
  173.     bls    4f
  174. 3:    clrl    d0
  175.     rts
  176. 4:    bclr    #31,d0        
  177.     cmpl    #0x7ff00000,d0    | First operand == NaN =?
  178.     bgt    3b
  179.     blt    5f        | It is finite!
  180.     tstl    d1
  181.     bne    3b        | It *is* a NaN
  182. 5:    moveql    #-1,d0        | Test True
  183.     rts
  184.