OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 12:18 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Invalid GCC Inline?
PostPosted: Sat Jun 07, 2008 7:40 pm 
Offline
Member
Member
User avatar

Joined: Thu Jan 04, 2007 3:29 pm
Posts: 1466
Location: Noricum and Pannonia
In the wiki, there is code such as:
Code:
asm ("lidt (%0)": :"p" (&IDTR));

However, has anyone noticed that with -O2 optimizations (gcc-4.1.2), it yields:
Code:
error: invalid 'asm': invalid expression as operand

Should we make note of this on the wiki? Fix?

_________________
C8H10N4O2 | #446691 | Trust the nodes.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 8:19 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
My solution?

-asm ("lidt (%0)": :"p" (&IDTR));
+asm ("lidt (%0)": :"r" (&IDTR));

Just an idea, seems to work with optimizations.. 8)

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


Top
 Profile  
 
 Post subject: Re: Invalid GCC Inline?
PostPosted: Sat Jun 21, 2008 12:01 am 
Offline
Member
Member
User avatar

Joined: Tue Dec 25, 2007 6:03 am
Posts: 734
Location: Perth, Western Australia
I normally use __asm__ __volatile__ (...) for inline asm. It may be that -O2 removes the use of asm(...)

_________________
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc


Top
 Profile  
 
 Post subject: Re: Invalid GCC Inline?
PostPosted: Sat Jun 21, 2008 9:00 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 03, 2007 6:03 am
Posts: 536
Location: Cambridge, UK
it depends on your compiler i think, DJGPP uses __asm__ __volatile__ ...

_________________
~ Lukem95 [ Cake ]
Release: 0.08b
Image


Top
 Profile  
 
 Post subject: Re: Invalid GCC Inline?
PostPosted: Tue Jun 24, 2008 5:17 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
lukem95 wrote:
it depends on your compiler i think, DJGPP uses __asm__ __volatile__ ...

So does gcc...
Jules


Top
 Profile  
 
 Post subject: Re: Invalid GCC Inline?
PostPosted: Tue Jun 24, 2008 10:21 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
DJGPP == GCC for DOS.

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


Top
 Profile  
 
 Post subject: Re: Invalid GCC Inline?
PostPosted: Wed Jun 25, 2008 5:29 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
Brynet-Inc wrote:
DJGPP == GCC for DOS.

Sorry didn't know that (never used DJGPP...) :oops:
Jules


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 29 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