Subject: Re: Serial IO focusing
From: [email-masked] (Tim Iverson)

24 Aug 1997 09:12:00 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Original-To: [email-masked] (mark koi)
Original-Cc: [email-masked]
In-Reply-To: <[email-masked]> from "mark koi" at Aug 20, 97 04:31:39 pm
X-Mailer: ELM [version 2.4 PL25]
Original-Sender: [email-masked]

Cygnus may have some of these already coded in their machine.h file, but if
you don't find it there, most folks usually just write their own using
GCC's inline asm; eg. in your very own machine.h file ...

static unsigned char inline
inb (const unsigned short port)
{
	register unsigned char val;

	__asm __volatile ("inb %%dx,%%al" : "=a" (val) : "d" (port));
	return val;
}

If I managed to remember the gas syntax for inb correctly,

{
	int x = inb(0x3f8);
}

Will produce the following assembly

	movw	%dx, $0x3f8
	inb	%dx, %al
	movzbl	%al, -4(%epb)

Or something quite similar -- GCC is smart enough to keep 0x3f8 in a
register and not reload it every time if you're in a loop.  It will also
skip the move to automatic storage if it can and just use the value in AL.

There is some cryptic documentation on inline asm for GCC in the info files.
For the details, you will need to read the source -- particularly the
machine description file in gcc/config/i386/i386.md.  This is the only
place you can find the descriptions for the various register fields (eg.
the "=a") to use in the asm lines.

- Tim


+----------------
| Date: Wed, 20 Aug 1997 16:31:39 -0400
| From: mark koi <[email-masked]>
| To: [email-masked]
| Subject: Serial IO focusing
| 
| method.  Now I am trying to use gnu-win32, and I see no libraries for
| things like outp(), inp().  Can someone steer me in the right direction
| for examples/how-tos for controlling a serial port in WIN95.  The
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".