home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / driver6s / termin.asm < prev    next >
Assembly Source File  |  1990-03-13  |  3KB  |  140 lines

  1. ;  Russell Nelson, Clarkson University.  October 20, 1988
  2. ;  Copyright, 1988, 1989, Russell Nelson
  3.  
  4. ;   This program is free software; you can redistribute it and/or modify
  5. ;   it under the terms of the GNU General Public License as published by
  6. ;   the Free Software Foundation, version 1.
  7. ;
  8. ;   This program is distributed in the hope that it will be useful,
  9. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. ;   GNU General Public License for more details.
  12. ;
  13. ;   You should have received a copy of the GNU General Public License
  14. ;   along with this program; if not, write to the Free Software
  15. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  
  17.     include    defs.asm
  18.  
  19. code    segment byte public
  20.     assume    cs:code, ds:code
  21.  
  22.     org    80h
  23. phd_dioa    label    byte
  24.  
  25.     org    100h
  26. start:
  27.     jmp    start_1
  28.  
  29. int_pkt    macro
  30.     pushf
  31.     cli
  32.     call    their_isr
  33.     endm
  34.  
  35. their_isr    dd    ?
  36. packet_int_no    db    ?,?
  37.  
  38. handle        dw    ?
  39.  
  40. bogus_type    db    1,2,3,4,5,6,7,8        ;totally bogus type code.
  41.  
  42. signature    db    'PKT DRVR',0
  43. signature_len    equ    $-signature
  44.  
  45. no_signature_msg    db    "No packet driver at that address",'$'
  46. usage_msg    db    "usage: termin <packet_int_no>",'$'
  47.  
  48. usage_error:
  49.     mov    dx,offset usage_msg
  50. error:
  51.     mov    ah,9
  52.     int    21h
  53.     int    20h
  54.  
  55. start_1:
  56.     mov    si,offset phd_dioa+1
  57.     cmp    byte ptr [si],CR    ;end of line?
  58.     je    usage_error
  59.  
  60.     mov    di,offset packet_int_no
  61.     call    get_number
  62.  
  63.     mov    ah,35h            ;get their packet interrupt.
  64.     mov    al,packet_int_no
  65.     int    21h
  66.     mov    their_isr.offs,bx
  67.     mov    their_isr.segm,es
  68.  
  69.     lea    di,3[bx]
  70.     mov    si,offset signature
  71.     mov    cx,signature_len
  72.     repe    cmpsb
  73.     jne    no_signature_err
  74.  
  75.     push    ds
  76.     mov    ax,1ffh            ;driver_info
  77.     int_pkt
  78.     pop    ds
  79.     call    fatal_error
  80.  
  81.     mov    ah,2            ;access_type
  82.     mov    al,ch            ;their class from driver_info().
  83.     mov    bx,dx            ;their type from driver_info().
  84.     mov    dl,cl            ;their number from driver_info().
  85.     mov    cx,MAX_P_LEN        ;use the max type length.
  86.     mov    si,offset bogus_type
  87.     push    cs            ;es:di -> our receiver.
  88.     pop    es
  89.     mov    di,offset our_recv
  90.     int_pkt
  91.     call    fatal_error
  92.     mov    handle,ax
  93.  
  94.     mov    ah,5            ;terminate the driver.
  95.     mov    bx,handle
  96.     int_pkt
  97.     jnc    now_close
  98.     call    print_error
  99. now_close:
  100.     mov    ah,3            ;release_type
  101.     mov    bx,handle
  102.     int_pkt
  103.     jnc    now_done        ;if ok, we're done.
  104.     cmp    dh,BAD_HANDLE        ;if it succeeded, we'll get a bad handle.
  105.     je    now_done        ;it worked.
  106.     stc
  107.     call    fatal_error
  108. now_done:
  109.     int    20h
  110.  
  111.  
  112. our_recv:
  113.     or    ax,ax            ;first or second call?
  114.     jne    our_recv_1        ;second -- we ignore the packet
  115.     push    cs
  116.     pop    es
  117.     mov    di,offset our_buffer
  118. our_recv_1:
  119.     db    0cbh            ;masm 4.0 doesn't grok "retf"
  120.  
  121.  
  122. no_signature_err:
  123.     mov    dx,offset no_signature_msg
  124.     mov    ah,9
  125.     int    21h
  126.     int    20h
  127.  
  128.  
  129.     include    pkterr.asm
  130.     include    getnum.asm
  131.     include    skipblk.asm
  132.     include    getdig.asm
  133.     include    chrout.asm
  134.  
  135. our_buffer    label    byte
  136.  
  137. code    ends
  138.  
  139.     end    start
  140.