wanted: c compiler that outputs asm

Programming, for all ages and all languages.
Post Reply
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

wanted: c compiler that outputs asm

Post 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.
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: wanted: c compiler that outputs asm

Post by Velko »

I don't know if it is small enough for you, but GCC can do that.

Try -S -masm=intel options.
If something looks overcomplicated, most likely it is.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: wanted: c compiler that outputs asm

Post by Combuster »

cute little gcc, eh? :twisted:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: wanted: c compiler that outputs asm

Post by JackScott »

Well, gcc-core is smaller than the whole gcc package... :?
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Re: wanted: c compiler that outputs asm

Post by Alboin »

C8H10N4O2 | #446691 | Trust the nodes.
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: wanted: c compiler that outputs asm

Post 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 :lol:

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 :cry:
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 :wink:

3) Nwcc
http://wiki.osdev.org/Nwcc
Coooool 8)
must see - Hard to describe. :mrgreen:
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: wanted: c compiler that outputs asm

Post by AJ »

AhmadTayseerDajani wrote:2.2 AttoC Free C Compiler
http://www.geocities.com/SiliconValley/ ... /attoc.htm
not bad C compiler :wink:
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
froggey
Member
Member
Posts: 38
Joined: Tue Oct 17, 2006 10:21 pm
Location: Hampshire, UK

Re: wanted: c compiler that outputs asm

Post 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/
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

Re: wanted: c compiler that outputs asm

Post 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.
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: wanted: c compiler that outputs asm

Post 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
User avatar
TheDragon
Member
Member
Posts: 43
Joined: Mon Aug 25, 2008 8:23 pm
Location: Middle of Nowhere

Re: wanted: c compiler that outputs asm

Post 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
Post Reply