Page 1 of 1
wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 12:10 am
by kubeos
Hi,
Does anyone know of a small-c or tiny c compiler that spits out assembly (either nasm or fasm format)?
All the one's I've come across so far are for embedded targets like avr, pic, etc.
The reason I'm asking is because I FINALLY ported fasm to Kube OS and want something higher level to play with. I've managed a port of my zc compiler but it's not that great.
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 4:21 am
by Velko
I don't know if it is small enough for you, but GCC can do that.
Try -S -masm=intel options.
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 4:52 am
by Combuster
cute
little gcc, eh?
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 4:55 am
by JackScott
Well, gcc-core is smaller than the whole gcc package...
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 5:05 am
by Alboin
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 5:40 am
by i586coder
kubeos wrote:
Does anyone know of a small-c or tiny c compiler that spits out assembly (either nasm or fasm format)?
Well,there is many
1) 16 bit compiler
turbo c
TCC -S yourCFile.cpp
will generate yourCFile.asm
Note:the code is 286 TASM like syntax
2) 32 bit compiler
2.1
Digital Mars
http://www.digitalmars.com/
Unfortunately,commercial compiler
DMC -cod yourCFile.c
Generate .cod (assembler output) file
Causes obj2asm to be run on the .obj file output from the
compiler to generate a .cod file showing the assembly
code generated. Using this along with the -gl switch will
generate a mixed source/assembly .cod file.
2.2
AttoC Free C Compiler
http://www.geocities.com/SiliconValley/ ... /attoc.htm
not bad C compiler
3)
Nwcc
http://wiki.osdev.org/Nwcc
Coooool
must see - Hard to describe.
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 6:10 am
by AJ
Not bad?
Free C Compiler Website wrote:In fact, this compiler does not even support all the major features of C. The biggest one's that I can think of are listed below:
Pointers
Arrays
For loops
The only data type supported is int
The only C library function supported is printf()
My suggestion would be to avoid this one
Cheers,
Adam
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 6:56 am
by froggey
froggey's checklist for porting GCC!
Do you have:
- A function to create a process?
- Most of the C string.h functions?
- Most of the common C stdio.h functions? (fopen/fclose/fprintf/fread/etc)
- A way to get information about files? (stat)
- A way to read directories? (opendir/readir/closedir)
- Support for malloc/realloc/calloc/free?
- Time? (If you have time to write an OS, you probably have time to port GCC)
If you answered yes to all these questions, then with a little effort you should be able to port GCC!
But if that isn't your thing, you could also try:
PCC, the BSD's compiler:
http://pcc.ludd.ltu.se/
TCC, from the author of qemu:
http://bellard.org/tcc/
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 8:50 am
by kubeos
I'm sorry, I should have mentioned this.. I am working on a GCC port still... but I'm not happy with the size of it. Newlib's libc is over 2 megs.I think GCC compiled to 170k, which isn't too bad.
I'm really looking for some smaller tools. I DID find a small-c for Windows that came with the source last night, so I think with a little work I could probably port this to my OS.
I also found one for DexOS and KolibriOS which I believe are all based on the same sources.. so with a little work I should be able to get something working. Thanks for your replies.
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 03, 2008 10:58 am
by DeletedAccount
1) Tiny c compiler
2) SDCC
3) Small C compiler
4) Build your own , A decent subset of C can be parsed using an RDP
Regards
Sandeep
Re: wanted: c compiler that outputs asm
Posted: Fri Oct 10, 2008 10:04 pm
by TheDragon
Another more complicated way to do this is to find a good disassembler. That way you can use whatever compiler you want, in theory.
http://www.freeprogrammingresources.com
http://www.thefreecountry.com