public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Inline assembly and using of IN and OUT assembler instructions
@ 2006-05-14 10:30 majess
  0 siblings, 0 replies; only message in thread
From: majess @ 2006-05-14 10:30 UTC (permalink / raw)
  To: gcc-help

Hello,all
I've written two functions, which are responsible for writing and 
reading byte(8 bit char) from I/O space of x86 architecture processor 
(IBM T23 Pentium III laptop.).I need that functions to write drivers to 
use COM1(RS232) under Debian and utilizing GCC compiler. I have to work 
on registers.......and I can't use BIOS functions.

I'm using GNU/Debian operating system and GCC (ver. for Debian 4:4.0.2-2)
Below are presented functions which I wrote:

void OutPort(unsigned short int IO_port,char Value)
{
    asm("outb %%al,%%dx;"
    : //no output data
    :"d"(IO_port),"a"(Value) //input data (EDX<-IO_port; AL<-Value)
    );
}
char InPort(unsigned short int IO_port)
{
    asm("inb %%dx,%%al;"
    : //output data is in al register
    :"d"(IO_port) //input data (EDX<-IO_port AL<-Value)
    );
}

/*      Intel Syntax
        OUT PORT
        mov dx,IOport
        mov al,Value
        out dx,al
        IN PORT
        mov dx,IOport
        in al,dx
        mov rueck,al
*/
That functions with other code are compiled with GCC Compiler, but the 
program behaves like it execute operations to the moment when it 
encounter, for example InPort(0x3f0) or OutPort(0x3f0,'s'); statement 
and statements after that aren't performed.
I'd also say that I was using HOW-TO doc about GCC and inline 
assembly(http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html) 
as a manual.

To sum up:
Maybe somebody know how to fix that functions to work properly under GCC 
and Debian (maybe they don't work because of Debian restrictions to I/O 
space access ?)
Maybe one of this mailing group member has similar problem?
I will be very grateful for help.

Best regards,
Lukasz Majewski

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-14 10:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-14 10:30 Inline assembly and using of IN and OUT assembler instructions majess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).