C/C++ with inline nasm?
-
- Posts: 1
- Joined: Thu Jul 07, 2011 3:49 am
C/C++ with inline nasm?
Hello Community,
at first, sorry for my bad english. As the headline says, I'd like to work with nasm in C/C++ to develop my own os. The reason of this is because I'm a total asm beginner, but I've got some experience in C++, so it would be easier for me to combine C++ with NASM.
Does someone know a C/C++ compiler that supports inline NASM?
I hope for your help ,
Developer30
at first, sorry for my bad english. As the headline says, I'd like to work with nasm in C/C++ to develop my own os. The reason of this is because I'm a total asm beginner, but I've got some experience in C++, so it would be easier for me to combine C++ with NASM.
Does someone know a C/C++ compiler that supports inline NASM?
I hope for your help ,
Developer30
-
- Member
- Posts: 595
- Joined: Mon Jul 05, 2010 4:15 pm
Re: C/C++ with inline nasm?
The common C++ compilers support their own native version of inline assembler which are different among most compilers. I've not heard of any that supports NASM specific syntax.
I suggest you read the documentation of your chosen compiler in order to find out about inline assembler.
I suggest you read the documentation of your chosen compiler in order to find out about inline assembler.
Re: C/C++ with inline nasm?
The difference between intel and AT&T syntax isn't huge - I suggest you learn AT&T syntax.reason of this is because I'm a total asm beginner,
-
- Member
- Posts: 595
- Joined: Mon Jul 05, 2010 4:15 pm
Re: C/C++ with inline nasm?
Isn't there a GCC option where you can change the syntax to Intel?JamesM wrote:The difference between intel and AT&T syntax isn't huge - I suggest you learn AT&T syntax.reason of this is because I'm a total asm beginner,
AT&T syntax should be considered as torture these days. Are we really going to put beginners through that?
Re: C/C++ with inline nasm?
Yes, there is an option for gcc, namely “-masm=intel”. It's still slightly different from NASM syntax, but that difference is not too big.
Re: C/C++ with inline nasm?
Very much depends on when and where you learned ASM. I learned on a C64 assembler, the name of which I have long forgotten (we only called it "sys49152" as that was its start address), and I always found AT&T highly intuitive - and Intel syntax as "bass-ackwards".OSwhatever wrote:AT&T syntax should be considered as torture these days.
Another thing where the "Big Corps" have screwed the perception of the masses...
Every good solution is obvious once you've found it.
Re: C/C++ with inline nasm?
From a system architecture POV, this is very good advice. Out-of-line assembler is easier to identify, easier to refactor, easier to... everything.berkus wrote:Use out-of-line NASM for start, it is easier.
Every good solution is obvious once you've found it.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: C/C++ with inline nasm?
...Until you want to place said assembly in a C++ name mangled function, or template member function.
Re: C/C++ with inline nasm?
One, I don't see why you'd want to do that. Two, you can call an extern "C" assembler function from within a C++-mangled or templated function just fine...
Every good solution is obvious once you've found it.
Re: C/C++ with inline nasm?
Depends what you're used to, I guess. I've never really grown very proficient with either syntax (every assembly snippet in my OS has been a tiny nightmare on its own), but AT&T sounds more familiar to me, closer to natural language. In everyday life, I talk about moving something from a source to a destination, not to a destination from a source. Maybe it's due to me being French, and a native English speaker would rather use the latter, but to me it just sounds weird to put the end of a journey before its beginning in a sentence, except for intellectual masturbation or poetry purposes.OSwhatever wrote:AT&T syntax should be considered as torture these days. Are we really going to put beginners through that?
Re: C/C++ with inline nasm?
Blah blah blah holy war blah blah.Neolander wrote:Depends what you're used to, I guess. I've never really grown very proficient with either syntax (every assembly snippet in my OS has been a tiny nightmare on its own), but AT&T sounds more familiar to me, closer to natural language. In everyday life, I talk about moving something from a source to a destination, not to a destination from a source. Maybe it's due to me being French, and a native English speaker would rather use the latter, but to me it just sounds weird to put the end of a journey before its beginning in a sentence, except for intellectual masturbation or poetry purposes.OSwhatever wrote:AT&T syntax should be considered as torture these days. Are we really going to put beginners through that?
They're assembler syntaxes. Get over it. It's not like a paradigm shift of C versus Haskell or something.
Re: C/C++ with inline nasm?
Natural for some I presume. If you think about it, in C/C++, you do X = Y; X being dest, Y being source. Why does that seem natural in that context, yet backwards in another (asm). It really just depends on the person, nobody is right or wrong, just depends on how you view it.Neolander wrote:Depends what you're used to, I guess. I've never really grown very proficient with either syntax (every assembly snippet in my OS has been a tiny nightmare on its own), but AT&T sounds more familiar to me, closer to natural language. In everyday life, I talk about moving something from a source to a destination, not to a destination from a source. Maybe it's due to me being French, and a native English speaker would rather use the latter, but to me it just sounds weird to put the end of a journey before its beginning in a sentence, except for intellectual masturbation or poetry purposes.OSwhatever wrote:AT&T syntax should be considered as torture these days. Are we really going to put beginners through that?