GAS Syntax

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
crazygray1
Member
Member
Posts: 168
Joined: Thu Nov 22, 2007 7:18 pm
Location: USA,Hawaii,Honolulu(Seriously)

GAS Syntax

Post by crazygray1 »

Is there anything that changes in gcc inline asm when you use Intel syntax.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

Google is your best friend here and otherwise search this forum as the subject has only been addressed a few million times before.

gcc -v --help reveals a -masm option
google gcc masm reveals gcc -masm=intel

took about a minute :wink:
Author of COBOS
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Unfortunately, unless I misread the GCC info page, -masm=intel affects the output of GCC, i.e. what you get when you do gcc -S...
Every good solution is obvious once you've found it.
User avatar
crazygray1
Member
Member
Posts: 168
Joined: Thu Nov 22, 2007 7:18 pm
Location: USA,Hawaii,Honolulu(Seriously)

Post by crazygray1 »

I decided against intel syntax, here is my outb function

Code: Select all

void outb(uchar_t in, uint16_t outp)
{
	asm("outb %%al,%%dx"
	    : /*none to pass*/
	    :"a" (in),"d" (outp));
};
are there any errors?
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

Looks fine, except for the semicolon at the end.
The cake is a lie | rackbits.com
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: GAS Syntax

Post by jal »

crazygray1 wrote:Is there anything that changes in gcc inline asm when you use Intel syntax.
See here or here. Basically, use ".intel_syntax noprefix" in your assembly. Cannot find whether there's an easier way.


JAL
User avatar
crazygray1
Member
Member
Posts: 168
Joined: Thu Nov 22, 2007 7:18 pm
Location: USA,Hawaii,Honolulu(Seriously)

Post by crazygray1 »

ucosty wrote:Looks fine, except for the semicolon at the end.
What's wrong with the semicolon? It doesn't need to be there but it doesn't cause any problems.
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

It's just weird that you would put one there where none is needed. Thats all.
The cake is a lie | rackbits.com
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

The semicolon at the end of that function is Just Wrong (tm).
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

crazygray1 wrote:
ucosty wrote:Looks fine, except for the semicolon at the end.
What's wrong with the semicolon? It doesn't need to be there but it doesn't cause any problems.
I think they blew up an satellite once because of a semicolon (or other character) so i would be hesitant with you remark.

@solar
Oops, my bad. I should verify before i post ](*,)
Author of COBOS
Post Reply