home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm_kit / flushit.asm < prev    next >
Assembly Source File  |  1985-06-21  |  1KB  |  40 lines

  1. ;ROUTINE TO FLUSH A CIRCULAR BUFFER
  2. ;
  3. flushit       proc   far
  4. ;
  5.               push   di                ;save registers
  6.               push   dx
  7.               push   cx
  8. ;
  9. ;get the bytes from the buffer
  10.               mov    cx,guage          ;get the count
  11.               jcxz   flushitexit       ;check for empty
  12.               mov    di,0              ;initialize destination
  13. ;
  14. ;loop to get all the bytes
  15. flushit1:
  16.               mov    al,cbuff[si]      ;get the character
  17.               inc    si                ;increment the pointer
  18.               cmp    si,cbuffsize      ;wrap it?
  19.               jne    flushit2          ;skip if no wrap
  20.               mov    si,0              ;wrap the buffer pointer
  21. ;
  22. flushit2:
  23.               mov    lbuff[di],al      ;put byte in linear buffer
  24.               inc    di
  25.               loop   flushit1          ;loop until all bytes in lbuff
  26. ;
  27. ;send the linear buffer to the disk
  28.               mov    cx,guage          ;this is the number of bytes
  29.               lea    dx,lbuff          ;this is where they are
  30.               call   writefile         ;send them out
  31.               mov    guage,0           ;set circular buffer empty
  32. ;
  33. flushitexit:
  34.               pop    cx                ;restore registers
  35.               pop    dx
  36.               pop    di
  37.               ret
  38. ;
  39. flushit       endp
  40.