[net.micro.pc] LOW LEVEL I/O PROBLEM - FIRST READ IS GARBAGE, NEXT ARE ONE BEHIND.

ijk@houxt.UUCP (05/20/84)

I've been playing around with interfacing with the ROM BIOS and DOS
function calls.  (I'm using standard assembler to do the low-level
work, with interfaces provided to 'C", per standard conventions).
When I try to interface to the Async device, I run into a weird problem
when I put my modem into analog loopback:
	-----------------------------------------
	/* the code looks like this */
	int i,inp;

	for (i=0; i<= 255; i++) {

		writecom(i);	/* send out char over port */
		inp = readcom();	/* read char back in */

		if ( i != inp)
			printf("i = %x, inp = %x\n");
		}
	/* writecom and readcom can either be DOS func 3 & 4 or
	 * calls to the ROM BIOS; no difference
	 */
	-------------------------------------------

The first char read is ALWAYS GARBAGE - from then on, I'm one char 
BEHIND (i.e., when i = 1, inp = 0, etc.).  It would appear at
first glance that a 1 char buffer is somehow inserted into the system,
but if I do a read first, I just hang, waiting for a char.

What's going on????  If anyones interested, I'll send them actual
assembler code as well.

Thanx in advance.
Ihor Kinal
houti!ijk