home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / driver6s / pktchk.asm < prev    next >
Assembly Source File  |  1990-04-10  |  4KB  |  182 lines

  1. version    equ    0
  2.  
  3. ;  Russell Nelson, Clarkson University.  October 20, 1988
  4. ;  Copyright, 1988, 1989, Russell Nelson
  5. ;  Modified TERMIN.ASM to be PKTCHK.ASM return errorlevel, don't terminate
  6. ;    07/24/89 Glen Marianko, Albert Einstein College of Medicine
  7.  
  8. ;   This program is free software; you can redistribute it and/or modify
  9. ;   it under the terms of the GNU General Public License as published by
  10. ;   the Free Software Foundation, version 1.
  11. ;
  12. ;   This program is distributed in the hope that it will be useful,
  13. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;   GNU General Public License for more details.
  16. ;
  17. ;   You should have received a copy of the GNU General Public License
  18. ;   along with this program; if not, write to the Free Software
  19. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.     include    defs.asm
  22.  
  23. code    segment byte public
  24.     assume    cs:code, ds:code
  25.  
  26.     org    80h
  27. phd_dioa    label    byte
  28.  
  29.     org    100h
  30. start:
  31.     jmp    start_1
  32.  
  33. copyleft_msg    label    byte
  34.  db "Packet checker version ",'0'+majver,".",'0'+version," copyright 1990, Russell Nelson.",CR,LF
  35.  db "This program is free software; see the file COPYING for details.",CR,LF
  36.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  37.  
  38. int_pkt    macro
  39.     pushf
  40.     cli
  41.     call    their_isr
  42.     endm
  43.  
  44. their_isr    dd    ?
  45. packet_int_no    db    0,0
  46.         db    0,0        ; filler for print_number
  47. packet_int_end  db    0,0
  48. signature    db    'PKT DRVR',0
  49. signature_len    equ    $-signature
  50. got_int        db    0
  51. no_signature_msg    db    "Packet driver not found.",CR,LF,'$'
  52. signature_msg    db    "Packet driver found at ",'$'
  53. no_signatures_msg    db    "No packet driver found in specified range.",CR,LF,'$'
  54. usage_msg    db    "usage: pktchk <packet_int_no> (packet_int_no_end)",CR,LF,'$'
  55.  
  56. usage_error:
  57.     mov    dx,offset usage_msg
  58. error:
  59.     mov    ah,9
  60.     int    21h
  61. err_quit:
  62.     mov    al,1
  63.         mov     ah,04ch                 ; exit with errorlevel 1
  64.         int     21h
  65.  
  66. start_1:
  67.     mov    si,offset phd_dioa+1
  68.     call    skip_blanks
  69.     cmp    al,CR            ;end of line?
  70.     je    usage_error
  71.  
  72.     mov    di,offset packet_int_no
  73.     call    get_number
  74.     cmp    packet_int_no+1,0
  75.     jne    usage_error
  76.  
  77.     mov    di,offset packet_int_end
  78.     call    get_number
  79.     cmp    packet_int_end+1,0
  80.     jne    usage_error
  81.     mov    di,si
  82.     call    skip_blanks
  83.     cmp    al,CR            ;end of line?
  84.     jne    usage_error
  85.  
  86.     cmp    packet_int_end,0
  87.     jne    chk_range        ; second arg specified
  88.  
  89.     call    chk_int
  90.     jne    no_signature_err
  91.     call    pkt_found
  92. done:
  93.     mov    al,0
  94.     mov    ah,04ch
  95.     int    21h            ; exit with errorlevel 0
  96.  
  97. no_signature_err:
  98.     mov    dx,offset no_signature_msg
  99.     jmp    error
  100.  
  101. chk_range:
  102.     mov    al,packet_int_end
  103.     sub    al,packet_int_no
  104.     jc    usage_error
  105.  
  106. chk_loop:
  107.     call    chk_int
  108.     jne    chk_none
  109.     call    pkt_found
  110.     inc    got_int            ; flag we got one
  111. chk_none:
  112.     mov    al,packet_int_no
  113.     cmp    packet_int_end,al
  114.     jz    no_signatures_chk
  115.     inc    packet_int_no        ; increment
  116.     jmp    chk_loop
  117.  
  118. no_signatures_chk:
  119.     cmp    got_int,0
  120.     jnz    done
  121.  
  122. no_signatures:
  123.     mov    dx,offset no_signatures_msg
  124.     jmp    error
  125.  
  126.     public    chk_int
  127. chk_int:
  128.     mov    ah,35h            ;get their packet interrupt.
  129.     mov    al,packet_int_no
  130.     int    21h
  131.     mov    their_isr.offs,bx
  132.     mov    their_isr.segm,es
  133.     lea    di,3[bx]
  134.     mov    si,offset signature
  135.     mov    cx,signature_len
  136.     repe    cmpsb
  137.     ret
  138.  
  139.     public    pkt_found
  140. pkt_found:
  141.     mov    dx,offset signature_msg
  142.     mov    di,offset packet_int_no
  143.     jmp    print_number
  144.  
  145.     include    getnum.asm
  146.     include    skipblk.asm
  147.     include    getdig.asm
  148.     include    decout.asm
  149.     include    digout.asm
  150.     include    chrout.asm
  151.  
  152. print_number:
  153. ;enter with dx -> dollar terminated name of number, di ->dword.
  154. ;exit with the number printed and the cursor advanced to the next line.
  155.     mov    ah,9            ;print the name of the number.
  156.     int    21h
  157.     mov    al,'0'
  158.     call    chrout
  159.     mov    al,'x'
  160.     call    chrout
  161.     mov    ax,[di]            ;print the number in hex.
  162.     mov    dx,[di+2]
  163.     call    dwordout
  164.     mov    al,' '
  165.     call    chrout
  166.     mov    al,'('
  167.     call    chrout
  168.     mov    ax,[di]            ;print the number in decimal.
  169.     mov    dx,[di+2]
  170.     call    decout
  171.     mov    al,')'
  172.     call    chrout
  173.     mov    al,CR
  174.     call    chrout
  175.     mov    al,LF
  176.     call    chrout
  177.     ret
  178.  
  179. code    ends
  180.  
  181.     end    start
  182.