home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / bp_6_93 / bonus / winer / comparef.asm < prev    next >
Assembly Source File  |  1992-05-12  |  1KB  |  58 lines

  1. ;********* COMPAREF.ASM, compares floating point numbers
  2.  
  3. ;Copyright (c) 1991 Ethan Winer
  4.  
  5. ;NOTE: Assemble this file with MASM 5.1 using the /e (emulator) switch.
  6.  
  7.  
  8. .Model Medium, Basic
  9.   Extrn B$FCMP:Proc         ;this is BASIC's floating point compare routine
  10.  
  11. .8087                       ;allow coprocessor instructions
  12. .Code
  13.  
  14. CompareSP Proc, Var1:Word, Var2:Word
  15.  
  16.   Mov  BX,Var2              ;get the address of Var1
  17.   Fld  DWord Ptr [BX]       ;load it onto the 8087 stack
  18.   Mov  BX,Var1              ;same for Var2
  19.   Fld  DWord Ptr [BX]
  20.   FWait                     ;wait until the 8087 says it's okay
  21.   Call B$FCMP
  22.  
  23.   Mov  AX,0                 ;assume they're the same
  24.   Je   Exit                 ;we were right
  25.   Mov  AL,1                 ;assume Var1 is greater
  26.   Ja   Exit                 ;we were right
  27.   Dec  AX                   ;Var1 must be less than Var2
  28.   Dec  AX                   ;decrement AX to -1
  29.  
  30. Exit:
  31.   Ret                       ;return to BASIC
  32.  
  33. CompareSP Endp
  34.  
  35.  
  36.  
  37. CompareDP Proc, Var1:Word, Var2:Word
  38.  
  39.   Mov  BX,Var2              ;as above
  40.   Fld  QWord Ptr [BX]
  41.   Mov  BX,Var1
  42.   Fld  QWord Ptr [BX]
  43.   FWait
  44.   Call B$FCMP
  45.  
  46.   Mov  AX,0
  47.   Je   Exit
  48.   Mov  AL,1
  49.   Ja   Exit
  50.   Dec  AX
  51.   Dec  AX
  52.  
  53. Exit:
  54.   Ret
  55.  
  56. CompareDP Endp
  57. End
  58.