# first-in first-out program

Status
Not open for further replies.

#### ci139

##### Active Member
maybe http://www.tenouk.com/ModuleZ.html -- about memory allocation functions
http://www.csd.uoc.gr/~hy534/00a/sec3.html#s34.data_str -- harware implemented but the basic ideas apply also to programmed data structures
http://ciechanowski.me/blog/2014/03/05/exposing-nsmutablearray/ -- educational extending the scope

you better exact at what platform in which environment e.c. and how (what exactly) you need to implement
(usually there is no questions if you have these points set clear to yourself)

#### ci139

##### Active Member
small stuff
as function names and syntax

. . . at the i made a major step forward getting started with graphics program though my experience at that time about the particular programming language was near zero -- it's that the step wise achieved output motivated to complete this complex starter project (it's not where you start (not much) but that you do and keep going)

#### ci139

##### Active Member
How to make c program for given table ?
what exactly you want to do
? in which c
? in which os/platform

#### Pommie

##### Well-Known Member
I have yet to understand a single post of your's ci139.

Mike.

#### ci139

##### Active Member
[...about.txt] -- a documentation of need to know stuff
for implementing
a stupid javascript fifo [...TEST-1.html] which i doubt does (in a sense of memory allocation) what i think it should (but will do as a poor and impossible for you to grasp example . . . . . . . . . . . . haa , haa , haa , haa )

// tested in Opera and IE for now also MZ.FF -- PS! -- but since it late here , i do not dispose my objects correctly -- as in about.txt -- all data fields of the popped elements must be cleared and their references set to undefined or deleted -- the proper structure/method would be reading all data into some permanent or temporary fetch variable from the element popped from the FiFo then erasing the popped Element ...

#### Attachments

• 5.3 KB Views: 19
• 2.9 KB Views: 57
Last edited:

#### Pommie

##### Well-Known Member
I often use a fifo to store received characters via serial interrupt.
This is how I implement it in C.
Code:
#include <xc.h>
#include "fifo.h"

#define FifoLength 32
unsigned char FifoBuffer[FifoLength];
unsigned char *FifoStart;
unsigned char *FifoEnd;
unsigned char count;

void InitFifo(void){
FifoStart=FifoBuffer;
FifoEnd=FifoBuffer;
count=0;
}

void PutFifo(unsigned char chr){
*FifoEnd++=chr;
count++;
if(FifoEnd==FifoBuffer+FifoLength)      //reached end
FifoEnd=FifoBuffer;                 //yes so wrap
//fifo full so deal with it!!
}
}

unsigned char GetFifo(void){
unsigned char chr;
while(FifoStart==FifoEnd);              //if fifo empty then wait
chr=*FifoStart++;
count--;
if(FifoStart==FifoBuffer+FifoLength)    //wrapped?
FifoStart=FifoBuffer;               //yes
return(chr);
}

unsigned char FifoCount(void){
return(count);
}
Mike.

Status
Not open for further replies.