home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / mscwattc / src / asmpkt.asm next >
Encoding:
Assembly Source File  |  1992-01-17  |  1.9 KB  |  96 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 [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 in ES:DI (see found: below)
  60.     sub    DI, 2
  61.  
  62. found:
  63.     push    DS            ; Copy bufseg to ES for return to TSR
  64.     pop    ES
  65.     add    DI, 2            ; Adjust pointer past flag word 
  66.     pop    DS
  67.     pop    CX
  68.     popf
  69.     retf                ; Buffer address returned to TSR in ES:DI
  70.  
  71.     ; encue packet
  72.     ;
  73. encue:    or    SI, SI
  74.     jz    no_enqu        ; not a valid pointer, cannot encue
  75.     push    SI
  76.     sub    SI, 2
  77.     mov    AL, 1        ; should be already, but just in case
  78.     mov    byte ptr [SI], AL
  79.     pop    SI
  80. no_enqu:popf
  81.     retf
  82. cendp    _pktentry
  83.  
  84. cpublic _pktasminit        ; bufptr, maxbufs, buflen
  85.     mov    AX, +@AB + 0 [BP]    ; bufptr
  86.     mov    BX, +@AB + 2 [BP]    ; bufptr segment
  87.     mov    CX, +@AB + 4 [BP]    ; maxbufs
  88.     mov    DX, +@AB + 6 [BP]    ; buflen
  89.     mov    CS:bufs, AX
  90.     mov    CS:bufseg, BX
  91.     mov    CS:maxbufs, CX
  92.     mov    CS:maxlen, DX
  93. creturn _pktasminit
  94. cend    ASMPKT
  95.         end
  96.