home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / advmsdos / chap13 / test0div.asm next >
Encoding:
Assembly Source File  |  1988-10-01  |  1.8 KB  |  94 lines

  1.          title     TEST0DIV - test for ZERODIV.COM
  2.          page      55,132
  3.  
  4. ;
  5. ; TEST0DIV.ASM:  Test program for the ZERODIV.ASM
  6. ;                divide-by-zero interrupt handler
  7. ;
  8. ; Copyright (C) 1988 Ray Duncan
  9. ;
  10. ; Build:   MASM TEST0DIV;
  11. ;          LINK TEST0DIV;
  12. ;
  13. ; Usage:   ZERODIV     (load divide by zero handler) 
  14. ;          TEST0DIV    (exercise the handler)
  15. ;
  16.  
  17. cr    equ    0dh              ;ASCII carriage return
  18. lf    equ     0ah               ;ASCII line feed
  19.  
  20. _TEXT    segment    word public 'CODE'
  21.  
  22.     org    100H
  23.  
  24.     assume  cs:_TEXT,ds:_TEXT,es:_TEXT,ss:_TEXT
  25.  
  26. main       proc    near
  27.  
  28.         mov    dx,offset signon    ; display sign-on message
  29.         mov     ah,9
  30.     int     21h 
  31.     
  32.     mov    dx,0            ; try register divide
  33.     mov    ax,1
  34.     mov    bx,0
  35.     div    bx
  36.  
  37.     mov    dx,offset msg1        ; display success message
  38.     mov    ah,9
  39.     int    21h
  40.  
  41.     mov    dx,0            ; try direct divide
  42.     mov    ax,1
  43.     div    word ptr zerow
  44.  
  45.     mov    dx,offset msg2        ; display success message
  46.     mov    ah,9
  47.     int    21h
  48.  
  49.     mov    dx,0            ; try mod = 1 divide
  50.     mov    ax,1
  51.     mov    bx,offset zerow
  52.     dec    bx
  53.     div    word ptr [bx+1]
  54.  
  55.     mov    dx,offset msg3        ; display success message
  56.     mov    ah,9
  57.     int    21h
  58.  
  59.     mov    dx,0            ; try mod = 2 divide
  60.     mov    ax,1
  61.     mov    bx,0
  62.     div    word ptr [bx+offset zerow2]
  63.  
  64.     mov    dx,offset msg4        ; display success message
  65.     mov    ah,9
  66.     int    21h
  67.  
  68.     mov    ax,4c00h        ; exit to MS-DOS
  69.     int    21h
  70.  
  71. main       endp 
  72.  
  73. signon    db      cr,lf,'Zero Divide Test program',cr,lf,'$'
  74.  
  75. msg1    db    cr,lf,'Back from register divide',cr,lf,'$'
  76.  
  77. msg2    db    cr,lf,'Back from direct mem divide',cr,lf,'$'
  78.  
  79. msg3    db    cr,lf,'Back from mod = 1 divide',cr,lf,'$'
  80.  
  81. msg4    db    cr,lf,'Back from mod = 2 divide',cr,lf,'$'
  82.  
  83. zerob    db    0            ; byte-sized operand
  84. zerow    dw    0            ; word-sized operand
  85.  
  86.     db    256 dup (?)        ; some empty space
  87.  
  88. zerow2    dw    0
  89.  
  90. _TEXT   ends
  91.  
  92.            end       main
  93.  
  94.