home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / lib / mntc6846.zoo / patch / dfcmp.s < prev    next >
Encoding:
Text File  |  1994-06-16  |  2.0 KB  |  67 lines

  1.  ! C68 8 byte floating point compare routine
  2.  !-----------------------------------------------------------------------------
  3.  ! ported to 68000 by Kai-Uwe Bloem, 12/89
  4.  !  #1  original author: Peter S. Housel 6/3/89
  5.  !  #2  Redid register usage, and then added wrapper routine
  6.  !    to provide C68 IEEE compatibility.
  7.  !    Also added C68 test routines        Dave & Keith Walker    02/92
  8.  !  #3  Avoided corrupting passed value if negative    Dave Walker      04/92
  9.  !  #4  Added code to treat as equal if only different by a value
  10.  !    equivalent to a bit in the least significant position        05/92
  11.  !  #5    Changed entry point names for C68 v4.3 compatibility
  12.  !    Changed exit code for C68 v4.3 compatibility
  13.  !    Removed ACK entry points                -djw-    09/93    
  14.  !  #6    Removed "nearly equal" code as incorrect        -djw-    10/93
  15.  !-----------------------------------------------------------------------------
  16.  
  17.     .sect .text
  18.  
  19.     .define .Xdfcmp
  20.  
  21. SAVEREG    = 3*4        ! Size of saved registers on stack
  22.  
  23. !----------------------------------------
  24. !    sp    Return address
  25. !    sp+4    address of second operand
  26. !    sp+8    address of first operand
  27. !----------------------------------------
  28. .Xdfcmp:
  29.     movem.l    d2-d4,-(sp)        ! Save registers that will be corruptedd
  30.     move.l    SAVEREG+4(sp),a1    ! address of second operand
  31.     movem.l    (a1),d1/d2
  32.     move.l    SAVEREG+8(sp),a1    ! address of first operand
  33.     movem.l    (a1),d3/d4
  34.  
  35.     tst.l    d1        ! check sign bit of first operand
  36.     bpl    3f        ! ... and jump if not negative
  37.     neg.l    d2        ! negate 2nd half
  38.     negx.l    d1        ! ... and first half
  39.     eor.l    #0x80000000,d1    ! toggle sign bit
  40. 3:
  41.     tst.l    d3        ! check sign bit of second operand
  42.     bpl    6f        ! ... and jump if not negative
  43.     neg.l    d4        ! negate 2nd half
  44.     negx.l    d3        ! negate first half
  45.     eor.l    #0x80000000,d3    ! toggle sign bit
  46. 6:
  47.     cmp.l    d3,d1        ! compare first halves of operands
  48.     blt    lt
  49.     bgt    gt
  50.     cmp.l    d2,d4        ! compare second halves of operands
  51.     bhi    gt
  52.  
  53. eq:    move.l    #0,d0
  54.     bra    finish
  55.  
  56. lt:    move    #-1,d0
  57.     bra    finish
  58.  
  59. gt:    move    #1,d0
  60.  
  61. finish:
  62.     movem.l    (sp)+,d2-d4    ! restore changed registers
  63.     move.l    (sp)+,a1    ! get return address
  64.     add.l    #8,sp        ! remove 2 parameters from stack
  65.     jmp    (a1)        ! ... and return
  66.  
  67.