home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / wattcp.zip / ASMPKT.ASM next >
Assembly Source File  |  1991-06-17  |  2KB  |  95 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:test    AL, byte ptr DS:DI
  53.     jz    found
  54.     add    DI, CS:maxlen
  55.     add    DI, 2
  56.     loop    srcloop
  57.  
  58. no_fnd: xor    DI, DI        ; for whatever error, throw away the buffer
  59.     mov    DS, DI        ; by returning 0000:0000
  60.     sub    DI, 2
  61.  
  62. found:  push    DS
  63.     pop    ES
  64.     add    DI, 2
  65.     pop    DS
  66.     pop    CX
  67.     popf
  68.     retf
  69.  
  70.     ; encue packet
  71.     ;
  72. encue:    or    SI, SI
  73.     jz    no_enqu        ; not a valid pointer, cannot encue
  74.     push    SI
  75.     sub    SI, 2
  76.     mov    AL, 1        ; should be already, but just in case
  77.         mov     byte ptr DS:SI, AL
  78.     pop    SI
  79. no_enqu:popf
  80.     retf
  81. cendp    _pktentry
  82.  
  83. cpublic _pktasminit        ; bufptr, maxbufs, buflen
  84.     mov    AX, +@AB + 0 [BP]    ; bufptr
  85.     mov    BX, +@AB + 2 [BP]    ; bufptr segment
  86.     mov    CX, +@AB + 4 [BP]    ; maxbufs
  87.     mov    DX, +@AB + 6 [BP]    ; buflen
  88.     mov    CS:bufs, AX
  89.     mov    CS:bufseg, BX
  90.     mov    CS:maxbufs, CX
  91.     mov    CS:maxlen, DX
  92. creturn _pktasminit
  93. cend    ASMPKT
  94.         end
  95.