home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / MSDOS / WATTCP / UNZIPPED / WNWATTCP / SRC / ASMPKT.ASM next >
Encoding:
Assembly Source File  |  1991-09-10  |  1.8 KB  |  102 lines

  1. ;
  2. ;
  3. ;  Usage :
  4. ;    -pktentry
  5. ;    _pktasminit( void far * buffers, int maxbufs, int buflen)
  6. ;
  7. ;  (c) 1991 University of Waterloo,
  8. ;    Faculty of Engineering,
  9. ;    Engineering Microcomputer Network Development Office
  10. ;
  11. ;  version
  12. ;
  13. ;    0.1    22-May-1992   E. P. Engelke
  14. ;
  15. ;
  16.     include masmdefs.hsm
  17.     include model.hsm
  18.  
  19. codedef    ASMPKT
  20. datadef
  21.  
  22. datastart
  23. maxbufs    dw      0
  24. maxlen    dw      0
  25. bufs    dw      0
  26. bufseg    dw      0
  27. dataend
  28.  
  29. cstart    ASMPKT
  30.  
  31. cproc    _pktentry
  32.     pushf
  33.  
  34.     cli        ; no interruptions now
  35.  
  36.     or    AL, AL
  37.     jnz    encue   ; branch if was a 1 and must encue packet now
  38.  
  39.     ; buffer request operation
  40.     ; to check our buffers we will need the same DS seg, set it now
  41.     push    CX
  42.     push    DS
  43.     mov    DI, _DATA
  44.     mov    DS, DI
  45.     assume    DS:_DATA
  46.     les    DI, dword ptr DS:bufs
  47.  
  48.     ; check the packet length
  49.     cmp    CX, DS:maxlen
  50.     jg    no_fnd        ; pretend none were found
  51.  
  52.     mov    CX, DS:maxbufs
  53.     mov    AL, 0ffh
  54.  
  55. srcloop:test    AL, byte ptr ES:DI
  56.     jz    found
  57.     add    DI, DS:maxlen
  58.     add    DI, 2
  59.     loop    srcloop
  60.  
  61. no_fnd:    xor    DI, DI        ; for whatever error, throw away the buffer
  62.     mov    ES, DI        ; by returning 0000:0000
  63.     sub    DI, 2
  64.  
  65. found:    add    DI, 2
  66.     pop    DS
  67.     assume    DS:nothing
  68.     pop    CX
  69.     popf
  70.     retf
  71.  
  72.     ; encue packet
  73.     ;
  74. encue:    or    SI, SI
  75.     jz    no_enqu        ; not a valid pointer, cannot encue
  76.     push    SI
  77.     sub    SI, 2
  78.     mov    AL, 1        ; should be already, but just in case
  79.     mov    byte ptr DS:SI, AL
  80.     pop    SI
  81. no_enqu:popf
  82.     retf
  83. cendp    _pktentry
  84.  
  85. cpublic    _pktasminit        ; bufptr, maxbufs, buflen
  86.     push    ES
  87.     mov    AX, _DATA
  88.     mov    ES, AX
  89.     assume    ES:_DATA
  90.     mov    AX, +@AB + 0 [BP]    ; bufptr
  91.     mov    BX, +@AB + 2 [BP]    ; bufptr segment
  92.     mov    CX, +@AB + 4 [BP]    ; maxbufs
  93.     mov    DX, +@AB + 6 [BP]    ; buflen
  94.     mov    ES:bufs, AX
  95.     mov    ES:bufseg, BX
  96.     mov    ES:maxbufs, CX
  97.     mov    ES:maxlen, DX
  98.     pop    ES
  99. creturn    _pktasminit
  100. cend    ASMPKT
  101.     end
  102.