>>856
#define BUFSIZE 255
unsigned char buf[BUFSIZE] = {0};
size_t head = 0, tail = 0;

void push(unsigned char data)
{
assert(head < BUFSIZE);
buffer[head] = data;
++head;
if (head >= BUFSIZE) head = 0;
}

unsigned char pop()
{
unsigned char ret;
assert(tail < BUFSIZE);
ret = buf[tail];
++tail;
if (tail >= BUFSIZE) tail = 0;
return ret;
}