home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / PPPBCKP / SRC / SRC15B95.ZIP / TERMIN.ZIP / TERMIN.ASM < prev   
Assembly Source File  |  1998-01-17  |  4KB  |  187 lines

  1. version equ     1
  2.  
  3. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  4.  
  5. ;   This program is free software; you can redistribute it and/or modify
  6. ;   it under the terms of the GNU General Public License as published by
  7. ;   the Free Software Foundation, version 1.
  8. ;
  9. ;   This program is distributed in the hope that it will be useful,
  10. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ;   GNU General Public License for more details.
  13. ;
  14. ;   You should have received a copy of the GNU General Public License
  15. ;   along with this program; if not, write to the Free Software
  16. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.     include    defs.asm
  19.  
  20. code    segment word public
  21.     assume    cs:code, ds:code
  22.  
  23.     org    80h
  24. phd_dioa    label    byte
  25.  
  26.     org    100h
  27. start:
  28.     jmp    start_1
  29.  
  30. copyleft_msg    label    byte
  31.  db "Packet driver terminator version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version," copyright 1988-1992, Russell Nelson.",CR,LF
  32. crlf_msg    db    CR,LF,'$'
  33.  
  34. their_isr    dd    ?
  35. entry_point    db    ?,?
  36.  
  37. handle        dw    ?
  38.  
  39. bogus_type    db    0,0        ;totally bogus type code.
  40.  
  41. signature    db    'PKT DRVR',0
  42. signature_len    equ    $-signature
  43.  
  44. flagbyte    db    0
  45. S_OPTION    equ    8
  46.  
  47. usage_msg        db    "usage: termin [-s] <packet_int_no>",'$'
  48. no_signature_msg        db      " ■ No packet driver found at that address.",'$'
  49. ok_msg                  db      " ■ Packet driver unloaded.",'$'
  50.  
  51. usage_error:
  52.     mov    dx,offset usage_msg
  53. error:
  54.     mov    ah,9
  55.     int    21h
  56.     int    20h
  57.  
  58. start_1:
  59.     cld
  60.  
  61.     mov    dx,offset copyleft_msg
  62.     mov    ah,9
  63.     int    21h
  64.  
  65.     mov    si,offset phd_dioa+1
  66.     call    skip_blanks        ;end of line?
  67.     cmp    al,CR
  68.     je    usage_error
  69.  
  70. chk_options:
  71.     call   skip_blanks
  72.     cmp    al,'-'            ; any options?
  73.     je    more_opt
  74.     cmp    al,'/'
  75.     jne    no_more_opt
  76. more_opt:
  77.     inc    si            ; skip past option char
  78.     lodsb                ; read next char
  79.     or    al,20h            ; convert to lower case
  80.     cmp    al,'s'
  81.     jne    usage_error
  82.     or    flagbyte,S_OPTION
  83.     jmp    chk_options
  84. no_more_opt:
  85.  
  86.     mov    di,offset entry_point
  87.     call    get_number
  88.  
  89.     mov    ah,35h            ;get their packet interrupt.
  90.     mov    al,entry_point
  91.     int    21h
  92.     mov    their_isr.offs,bx
  93.     mov    their_isr.segm,es
  94.  
  95.     lea    di,3[bx]
  96.     mov    si,offset signature
  97.     mov    cx,signature_len
  98.     repe    cmpsb
  99.     jne    no_signature_err
  100.  
  101.     mov    ax,1ffh            ;driver_info
  102.     call    int_pkt
  103.     call    fatal_error
  104.  
  105.     mov    ah,2            ;access_type
  106.     mov    al,ch            ;their class from driver_info().
  107.     mov    bx,dx            ;their type from driver_info().
  108.     mov    dl,cl            ;their number from driver_info().
  109.     mov    cx,2            ;use type length 2.
  110.     mov    si,offset bogus_type
  111.     movseg    es,cs
  112.     mov    di,offset our_recv
  113.     call    int_pkt
  114.     call    fatal_error
  115.     mov    handle,ax
  116.  
  117.     test    flagbyte,S_OPTION
  118.     jz    not_stop
  119.     mov    ah,8            ; f_stop
  120.     call    int_pkt
  121.     jmp    now_done
  122. not_stop:
  123.  
  124.  
  125.     mov    ah,5            ;terminate the driver.
  126.     mov    bx,handle
  127.     call    int_pkt
  128.     jnc    now_close
  129.     call    print_error
  130. now_close:
  131.     mov    ah,3            ;release_type
  132.     mov    bx,handle
  133.     call    int_pkt
  134.     jnc    now_done        ;if ok, we're done.
  135.     cmp    dh,BAD_HANDLE        ;if it succeeded, we'll get a bad handle.
  136.     je    now_done        ;it worked.
  137.     stc
  138.     call    fatal_error
  139.     int    20h
  140. now_done:
  141.         push    cs
  142.         pop     ds
  143.         lea     dx,ok_msg
  144.         mov     ah,9
  145.         int     21h
  146.         int     20h
  147.  
  148.  
  149. our_recv:
  150.     or    ax,ax            ;first or second call?
  151.     jne    our_recv_1        ;second -- we ignore the packet
  152.     movseg    es,cs
  153.     mov    di,offset our_buffer
  154. our_recv_1:
  155.     retf
  156.  
  157.  
  158. no_signature_err:
  159.     mov    dx,offset no_signature_msg
  160.     mov    ah,9
  161.     int    21h
  162.     int    20h
  163.  
  164.  
  165. int_pkt:
  166.     push    ds
  167.     push    es
  168.     pushf
  169.     cli
  170.     call    their_isr
  171.     pop    es
  172.     pop    ds
  173.     ret
  174.  
  175.  
  176.     include    pkterr.asm
  177.     include    getnum.asm
  178.     include    skipblk.asm
  179.     include    getdig.asm
  180.     include    chrout.asm
  181.  
  182. our_buffer    label    byte
  183.  
  184. code    ends
  185.  
  186.     end    start
  187.