home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / CEREBRUM / WAT9609.ZIP / SRC / ASMPKT.ASM next >
Assembly Source File  |  1994-12-01  |  2KB  |  99 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. cstart  ASMPKT
  23.  
  24. maxbufs    dw    0
  25. maxlen    dw    0
  26. bufs    dw    0
  27. bufseg    dw    0
  28.  
  29. cproc    _pktentry
  30.     pushf
  31.  
  32.     cli        ; no interruptions now
  33.  
  34.     or    AL, AL
  35.     jnz    encue    ; branch if was a 1 and must encue packet now
  36.  
  37.     ; buffer request operation
  38.     ; to check our buffers we will need the same DS seg, set it now
  39.         push    CX
  40.     push    DS
  41.         mov     DI, CS:bufseg
  42.         mov     DS, DI
  43.  
  44.     ; check the packet length
  45.     cmp    CX, cs:maxlen
  46.     jg    no_fnd        ; pretend none were found
  47.  
  48.     mov    DI, CS:bufs
  49.     mov    CX, CS:maxbufs
  50.     mov    AL, 0ffh
  51.  
  52. srcloop:
  53. ;        test    AL, byte ptr DS:DI             ; 94.11.30 -- fix for tasm4
  54.         test    AL, byte ptr DS:[DI]
  55.     jz    found
  56.     add    DI, CS:maxlen
  57.     add    DI, 2
  58.     loop    srcloop
  59.  
  60. no_fnd: xor    DI, DI        ; for whatever error, throw away the buffer
  61.     mov    DS, DI        ; by returning 0000:0000
  62.     sub    DI, 2
  63.  
  64. found:  push    DS
  65.     pop    ES
  66.     add    DI, 2
  67.     pop    DS
  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             ; 94.11.30 -- fix for tasm4
  80.         mov     byte ptr DS:[SI], AL
  81.     pop    SI
  82. no_enqu:
  83.         popf
  84.     retf
  85. cendp    _pktentry
  86.  
  87. cpublic _pktasminit        ; bufptr, maxbufs, buflen
  88.     mov    AX, +@AB + 0 [BP]    ; bufptr
  89.     mov    BX, +@AB + 2 [BP]    ; bufptr segment
  90.     mov    CX, +@AB + 4 [BP]    ; maxbufs
  91.     mov    DX, +@AB + 6 [BP]    ; buflen
  92.     mov    CS:bufs, AX
  93.     mov    CS:bufseg, BX
  94.     mov    CS:maxbufs, CX
  95.     mov    CS:maxlen, DX
  96. creturn _pktasminit
  97. cend    ASMPKT
  98.         end
  99.