home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / TPL60N19 / ARISOURC / LONGABS.ASM < prev    next >
Assembly Source File  |  1993-01-25  |  1KB  |  46 lines

  1.  
  2. ; *******************************************************
  3. ; *                                                     *
  4. ; *     Turbo Pascal Runtime Library Version 6.0        *
  5. ; *     Longint Absolute Value                          *
  6. ; *                                                     *
  7. ; *     Copyright (C) 1991-1993 Norbert Juffa           *
  8. ; *                                                     *
  9. ; *******************************************************
  10.  
  11.              TITLE   LONGABS
  12.  
  13.  
  14. CODE         SEGMENT BYTE PUBLIC
  15.  
  16.              ASSUME  CS:CODE
  17.  
  18. ; Publics
  19.  
  20.              PUBLIC  LongAbs
  21.  
  22. ;-------------------------------------------------------------------------------
  23. ; LONG_ABS computes the absolute value of a four byte signed integer.
  24. ;
  25. ; INPUT:     DX:AX      longint number
  26. ;
  27. ; OUTPUT:    DX:AX      absolute value of longint number
  28. ;
  29. ; DESTROYS:  AX,DX,Flags
  30. ;-------------------------------------------------------------------------------
  31.  
  32. LongAbs      PROC    FAR
  33.              OR      DX, DX            ; number positive ?
  34.              JNS     $positive         ; yes, all done
  35.              NOT     DX                ; negate
  36.              NEG     AX                ;  number
  37.              SBB     DX, -1            ;   in DX:AX
  38. $positive:   RET                       ; done
  39. LongAbs      ENDP
  40.  
  41.              ALIGN   4
  42.  
  43. CODE         ENDS
  44.  
  45.              END
  46.