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

  1.          title     TRYINT24 -- tests critical error handler
  2.          page      55,132
  3. ;
  4. ; TRYINT24.ASM - Test program for INT24.ASM
  5. ;                replacement critical-error handler
  6. ;
  7. ; Copyright (C) June 1987 Ray Duncan
  8. ;
  9. ; Build:   MASM TRYINT24;
  10. ;          MASM INT24;
  11. ;          LINK TRYINT24+INT24;
  12. ;
  13. ; Usage:   TRYINT24
  14. ;
  15.  
  16. stdin    equ    0        ; standard input device
  17. stdout    equ    1        ; standard output device    
  18. stderr    equ    2        ; standard error device
  19.  
  20. cr    equ    0dh        ; ASCII carriage return
  21. lf    equ    0ah        ; ASCII line feed
  22.  
  23.  
  24. DGROUP    group    _DATA,STACK    ; 'automatic data group'
  25.  
  26.     extrn    get24:near
  27.     extrn    res24:near
  28.  
  29. _TEXT    segment    word public 'CODE'
  30.  
  31.     assume    cs:_TEXT,ds:DGROUP,ss:STACK
  32.  
  33. main    proc    far           ; entry point from MS-DOS
  34.  
  35.     mov    ax,DGROUP    ; set DS = our data segment
  36.     mov    ds,ax
  37.  
  38.     call    get24        ; capture int 24h for our
  39.                 ; own handler
  40.  
  41.                 ; display sign-on message...
  42.     mov    dx,offset DGROUP:msg    ; DS:DX = address of message
  43.     mov    cx,msg_len    ; CX = length of message
  44.     mov    bx,stdout    ; BX = handle for std output
  45.     mov    ah,40h        ; AH = 40h, write file or device
  46.     int    21h        ; transfer to MS-DOS
  47.  
  48. err:    mov    dl,'*'        ; write character to printer
  49.     mov    ah,05        ; to generate a critical error
  50.     int    21h
  51.     jmp    err
  52.  
  53.     call    res24        ; restore previous int 24h handler
  54.  
  55.     mov    ax,4c00h    ; no error, terminate program 
  56.     int    21h        ; with return code = 0
  57.  
  58. main2:    call    res24        ; restore previous int 24h handler
  59.  
  60.     mov    ax,4c01h    ; error, terminate program
  61.     int    21h        ; with return code = 1 
  62.  
  63. main    endp            ; end of main procedure
  64.  
  65. _TEXT    ends
  66.  
  67.  
  68. _DATA    segment    word public 'DATA'
  69.  
  70. msg    db    cr,lf,'Int 24H Handler Demo',cr,lf
  71. msg_len    equ    $-msg
  72.  
  73. _DATA    ends
  74.  
  75.  
  76. STACK    segment    para stack 'STACK'
  77.  
  78.     dw    64 dup (?)
  79.  
  80. STACK    ends
  81.  
  82.     end    main        ; defines program entry point
  83.  
  84.