TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: JAMES VAHN
from: DARRYL GREGORASH
date: 1998-01-17 19:02:00
subject: circular buffer

Replying to a message of James Vahn to Darryl Gregorash:
 JV>>> Sounds good to me. Use ES:DI, DS:SI and CX in conjunction
 JV>>> with REP MOVSB and I think you'll find an easy solution
 JV>>> for your  buffer.
 >> 
 >> Much easier just to "move" a couple of pointers, not gobs of
 >> data :)
 JV> I don't think you described a circular buffer..  
 JV> Whadya mean: 'buffer is empty' head=tail ?  
 JV> That's a stacked buffer. 
Ummm.. a stack _is_ a LIFO buffer.. you read from and write to the stack 
using the "head" pointer. If you re-read, I said "write at the tail, read 
from the head", and that is a FIFO buffer, a queue.
The only reason you ever need a separate "tail" pointer with a stack is in 
the case of a circular stack, and then only if you wish to prevent data loss 
after a wrap-around ([head+1]mod stack_size = tail, the stack is full.. you 
cannot push more data onto it without losing the value at the bottom of the 
stack).. not that I can imagine why one would want to prevent such overwrite, 
but I suppose it might be desirable in some cases.
 JV> Otherwise you're right, fiddling with the pointers might not
 JV> be easier but certainly faster than moving gobs of data.
Take another look at my code.. it is much easier than fiddling with gobs of 
data. Just as I used LODSB to read from the queue, I would use STOSB to write 
to it :)
--- FleetStreet 1.21 NR
---------------
* Origin: BIG BANG Burger Bar: Regina SK Canada (1:140/86)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.