OSDev.org

The Place to Start for Operating System Developers
It is currently Tue May 07, 2024 4:51 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: long outport help [FIXED]
PostPosted: Wed Feb 07, 2007 5:13 pm 
Offline
Member
Member

Joined: Wed Dec 20, 2006 7:56 pm
Posts: 237
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!


Last edited by GLneo on Wed Feb 07, 2007 6:43 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 6:22 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
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.. :)

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 6:42 pm 
Offline
Member
Member

Joined: Wed Dec 20, 2006 7:56 pm
Posts: 237
that worked!, thx!, but what was i doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 6:48 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
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

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 1:54 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], DotBot [Bot], Gigasoft and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group