C Compiler & Assembler

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
david_d

C Compiler & Assembler

Post by david_d »

I need a C compiler and an assembler. I don't want to use gcc because it uses gas (which uses the AT&T syntax). Is there a way to use nasm as inline asm? Or is there another compiler which uses an intel-syntax assembler?
Ozguxxx

Re:C Compiler & Assembler

Post by Ozguxxx »

Check this out: (This is exactly what you want but I dont know how to get it and dont know if anybody uses it...) :)
http://www.intel.com/software/products/ ... /index.htm
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:C Compiler & Assembler

Post by Pype.Clicker »

you can use intel syntax within nasm, using something like ".syntax intel noprefix" -- dive into the search (should have been discussed last summer or something alike) to learn more about it...

that's an undocumented feature, but it seems to works pretty well ... And i doubt you can find a better free C compiler than GCC :-)
david_d

Re:C Compiler & Assembler

Post by david_d »

This is exactly what you want ..
Looks good ...
... but I dont know how to get it ...
:P
you can use intel syntax within nasm
do you mean within gas? nasm uses intel syntax does'nt it?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:C Compiler & Assembler

Post by Pype.Clicker »

err yes. Typo from me ... must have been a girl walking in the hall nextby :) The trick is for using Intel syntax in GAS and GCC inline asm...
_mark

Re:C Compiler & Assembler

Post by _mark »

Personally I do not like inline asm at all. I much prefer to have ASM code in a seperate file and incure the cost of a function call. There are a few reasons for this. You can switch to a different C compiler at any time without worry of inline asm support, and the ASM code is much more readable when written correctly in its own file. I also find it much easier to debug.

That said, I've been using NASM and BCC for real mode and NASM and GCC for 32 bit mode.

Just my 2 cents
_mark()
Ozguxxx

Re:C Compiler & Assembler

Post by Ozguxxx »

Hi this might be some kind of off topic but I have heard people using perl for building os. How is it and why is it used? I mean why do you need perl interpreter for building os stuff? Thanx... BTW, I also donot like inline assembly->this is ontopic ;D
Tim

Re:C Compiler & Assembler

Post by Tim »

I use a Perl script as part of my build process, to extract PE DLL base addresses from the central COFFBASE.TXT and give them to ld.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:C Compiler & Assembler

Post by Pype.Clicker »

@ perl : it may make sense if you need to do some custom pre-processing on your source code to make it in perl as it is the best language for text manipulation (afaik). For instance, you can quickly write a perl script that will look up your C files and find a sequence like

Code: Select all

initializor(<level>) <function name>( ... ) { ... }
and group initializor functions by increasing level in an array, so that all your kernel_init() function has to do to startup every component is

Code: Select all

#include "autoinit.c"
   for (i=0;i<INITIALIZORS;i++) initializors[i].init()

@ inline asm:
it should usually be avoided everytime possible. However, there is one case where it can be very interresting: when you declare inline functions to perform some common operations (like reading one of the CRx register, for instance, or perform input/output operations).
If you have these operations as real asm function in a separated file, all the compiler can do is pushing arguments, and calling the asm function -- which can lead to severe performances penalties is the code is called repeatedly.

Using an inline function, the compiler can emit the asm code directly in your caller function, and it can perform some automatic registers allocation, so that the performances of the resulting code will approach what you would have if you had inserted the ASM code manually ...
RicoSanchez

Re:C Compiler & Assembler

Post by RicoSanchez »

Is it expecially perl that is great for text manipulation, or is it just that a flexible scripting language with powerfull regex functionality is great for text manipulation (which perl is one of)?
_mark

Re:C Compiler & Assembler

Post by _mark »

Yes perl is a good scripting lang that has powerful regex and string functions.

Personally I have always been an awk & sed kind of man. That is only because old habbits are hard to break though.

_mark()
Post Reply