home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / WINER.ZIP / SQUARE.ASM < prev    next >
Assembly Source File  |  1993-08-05  |  867b  |  31 lines

  1. ;********** SQUARE.ASM - squares a double precision value
  2.  
  3. ;Copyright (c) 1991 Ethan Winer
  4.  
  5. ;Syntax: DECLARE FUNCTION Square#(Variable#)
  6. ;        Result = Square#(Value#)
  7.  
  8.  
  9. ;WARNING: This file must be assembled using /e (emulator)
  10.  
  11. .Model Medium, Basic
  12. .Code
  13. .8087                   ;allow 8087 instructions
  14.  
  15. Square Proc, InValue:Word, OutValue:Word
  16.  
  17.   Mov  BX,InValue       ;get the address for InValue
  18.   Fld  QWord Ptr [BX]   ;load InValue on the 8087 stack
  19.   Fmul QWord Ptr [BX]   ;multiply InValue by itself
  20.  
  21.   Mov  BX,OutValue      ;get the address for OutValue
  22.   Fstp QWord Ptr [BX]   ;store the result there
  23.   Fwait                 ;wait for the 8087 to finish
  24.  
  25.   Mov  AX,BX            ;return DX:AX holding the full
  26.   Mov  DX,DS            ;  address of the output value
  27.   Ret                   ;return to BASIC
  28.  
  29. Square Endp
  30. End
  31.