This is very bad. If there's one thing a computer is supposed to do, it's count. Arithmetic is applied counting and computers were designed to do it very quickly and very accurately. A computer that can't count from 0 to FFFF (aka "64K" or 65,535 in base ten) using a sixteen bit unsigned integer number type* to hold the value does not merit the title "computer" and should be called "expensive coaster" instead. Or maybe "small, rectangular Frisbee that doesn't loft well." (These are tiny, solid state PCs. Eminently throw-able.) Yes, I'm blaming the hardware again, but I'm willing to consider the perfidy of DOS 6.22 and this aged C++ compiler we have to use. The FIFO may be innocent of many of the crimes with which it was charged. It seems that when I instructed the PC to write 64K values to the FIFO, it was only writing 32K values and then the counter flipped over to 0, then 1, then 2, and so on. No wonder the Full Flag never turned on. It's as if I only have fifteen bits to work with. Even though I declared my counter as "unsigned" (meaning that the computer won't use the sixteenth bit to indicate whether the number is positive or negative), the computer isn't giving me my sixteenth bit! I even tried declaring my counter as a "long" integer so I'd have 32 bits, but it won't give me 32 bits either. I suppose there's a way around this. I could perhaps write a routine that forces the computer to count in base 28? Oooh! Sudden flash of insight: This counting problem might explain some of the erroneous values being written out to the FIFO because I use the counter to calculate the values and Never mind. I had the same problem with the 256 byte FIFO and the computer can certainly count up to 256.
*"Oh no! Techo-babble!" cries the reader.
"Don't worry. It's easier than you think." I explain, "The computer stores the number as ones and zeros in a memory location which holds sixteen ones and zeros. You can only count up so far with sixteen bits. Just think of it like the odometer on an old car. The odometer can't count past 99,999 because it's only got five digits to work with. When you drive the car 100,000 miles, the odometer has to flip back to 00,000. With sixteen bits, you can count up to 64K before you have to flip back to all zeros."
420 words | May 27, 2004 08:48 PM | Rocket science