-=>Quoting Benjamin L Mcgee to All <=-
LM>Does anybody have ideas about how to implement a simple circular
LM>buffer? I'm not sure if I am using the term circular buffer
LM>correctly so I'll try and explain what I'm looking for.
[...]
BLM>New data would always enter the buffer at the bottom, pushing old data
BLM>up. Any data that could not fit in the buffer would fall off the top.
BLM>Any help will be greatly appreciated. Thanks
Hi Ben;
What you are describing is a FIFO, or queue. They both work the same
in that the first element in will be the first element out. Since you
mentioned the word, "buffer", then I will presume that you are
thinking of a FIFO stack.
Also, when you stated. "Any data that could not fit in the buffer
would fall off the top." Are you saying that (overflow) data will be
lost? I don't think you want that, but I need to ask.
Second, since this an an assembly echo, can I presume that you are
developing an assembly subroutine for a higher-language mainline, or
will it be all in assembly?
Anyway, if you want a FIFO buffer, you need to have two pointers.
And, you will have at least two subroutines: One to pass the data
into the buffer - called 'put', and one to pull it off - caled 'get.'
You also should have two other functions: One to test if the buffer
is full, and the other to test if the buffer is empty. However, you
can make them part of the 'get' and 'put' subs, if you wish.
If this is what you are looking for, let me know and I can talk about
implementing the pointers.
--- Maximus/2 3.01
---------------
* Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88)
|