home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / dpl.zip / _DV1616.D < prev    next >
Text File  |  1988-07-11  |  896b  |  37 lines

  1. ; Doug's Programming Language  -- DPL, Version 2.22
  2. ; Copyright (c) 1988 Douglas S. Cody, All rights reserved.
  3. ;---------------------------------
  4. ; _DV1616 - DIVIDE TWO 16 BIT INTEGERS
  5. ;
  6. ; Entry conditions:
  7. ;    AX holds the divv...
  8. ;    BX holds the divisor
  9. ; Exit conditions:
  10. ;    STATUS = 00, good divide
  11. ;      AX holds the result
  12. ;      DX holds the remainder
  13. ;    STATUS = 01, divide by zero attempted
  14. ;      AX = 00
  15. ;
  16. SUBPGM    _DV1616
  17. BEGIN    _DV1616
  18.     OR    BX,BX        ; ANY VALUE?
  19.     JNE    @DIV_05        ; YES, CONTINUE ON...
  20.     MOV    STATUS,01    ; DIVISION BY ZERO ATTEMPTED
  21.     XOR    AX,AX        ; CLEAR THE RESULT
  22.     RET
  23. ;
  24. @DIV_05:
  25.     SUB    DX,DX        ; CLEAR MSB
  26.     TEST    AX,8000H    ; NEGATIVE?
  27.     JE    @DIV_10        ; NO, CONTINUE ON...
  28.     NEG    DX
  29. ;
  30. @DIV_10:
  31.     IDIV    BX
  32.     MOV    STATUS,00    ; STATUS = GOOD DIVIDE
  33.     RET
  34. ;
  35. ENDPGM    _DV1616
  36. ;
  37.