OSDev.org
https://forum.osdev.org/

long outport help [FIXED]
https://forum.osdev.org/viewtopic.php?f=1&t=12886
Page 1 of 1

Author:  GLneo [ Wed Feb 07, 2007 5:13 pm ]
Post subject:  long outport help [FIXED]

hi all,

In the OSWIKI thing , says:
Quote:
the functions sysOutLong and sysInLong are assembly language functions that make use of the OUTL and INPL Pentium assembly language instructions.
but i can't figure out how to write them, i've tried:
Code:
inline unsigned int inportl(unsigned int port)
{
    unsigned int result;
    asm volatile("inl %1, %0" : "=a" (result) : "dN" (port));
    return result;
}

inline void outportl(unsigned int port, unsigned int data)
{
    asm volatile("outl %1, %0" : : "dN" (port), "a" (data));
}
but it says:
Quote:
Error: suffix of operand invaled for "out"
thx!

Author:  Brynet-Inc [ Wed Feb 07, 2007 6:22 pm ]
Post subject: 

Code:
inline unsigned long inportl(unsigned short port)
{
   unsigned long result;
   __asm__ __volatile__("inl %%dx, %%eax" : "=a" (result) : "dN" (port));
   return result;
}

inline void outportl(unsigned short port, unsigned long data)
{
   __asm__ __volatile__("outl %%eax, %%dx" : : "d" (port), "a" (data));
}


This should be adequate.. :)

Author:  GLneo [ Wed Feb 07, 2007 6:42 pm ]
Post subject: 

that worked!, thx!, but what was i doing wrong?

Author:  Brynet-Inc [ Wed Feb 07, 2007 6:48 pm ]
Post subject: 

GLneo wrote:
that worked!, thx!, but what was i doing wrong?


I attached a unified patch... It should outline the changes I made ;)

Attachments:
for-GLneo.tar [10 KiB]
Downloaded 72 times

Author:  Combuster [ Thu Feb 08, 2007 1:54 am ]
Post subject: 

As if a diff would explain the difference between correct and broken code...

What you did was suggesting gcc to fill in the most optimizer-effective registers it could spare (using %1, %0). However, inports and outports work only with one pair of registers: DX and AL/AX/EAX. Since you didnt tell it, it'd try to fill in some random register which would obviously fail the assembly stage.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/