Invalid GCC Inline?

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Invalid GCC Inline?

Post by Alboin »

In the wiki, there is code such as:

Code: Select all

asm ("lidt (%0)": :"p" (&IDTR));
However, has anyone noticed that with -O2 optimizations (gcc-4.1.2), it yields:

Code: Select all

 error: invalid 'asm': invalid expression as operand
Should we make note of this on the wiki? Fix?
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

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.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Invalid GCC Inline?

Post by thepowersgang »

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
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Re: Invalid GCC Inline?

Post by lukem95 »

it depends on your compiler i think, DJGPP uses __asm__ __volatile__ ...
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Invalid GCC Inline?

Post by suthers »

lukem95 wrote:it depends on your compiler i think, DJGPP uses __asm__ __volatile__ ...
So does gcc...
Jules
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Invalid GCC Inline?

Post by Brynet-Inc »

DJGPP == GCC for DOS.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Invalid GCC Inline?

Post by suthers »

Brynet-Inc wrote:DJGPP == GCC for DOS.
Sorry didn't know that (never used DJGPP...) :oops:
Jules
Post Reply