delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/08/24/09:12:00

From: iverson AT cisco DOT com (Tim Iverson)
Subject: Re: Serial IO focusing
24 Aug 1997 09:12:00 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199708220548.WAA17194.cygnus.gnu-win32@stars.cisco.com>
Mime-Version: 1.0
Original-To: koi AT ssa DOT crane DOT navy DOT mil (mark koi)
Original-Cc: gnu-win32 AT cygnus DOT com
In-Reply-To: <33FB542A.8271A54F@ssa.crane.navy.mil> from "mark koi" at Aug 20, 97 04:31:39 pm
X-Mailer: ELM [version 2.4 PL25]
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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 <koi AT ssa DOT crane DOT navy DOT mil>
| To: gnu-win32 AT cygnus DOT com
| 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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019