Inline assembly and using of IN and OUT assembler instructions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux