Page 1 of 1

Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 7:46 am
by f2
I started an article that describes how to make a sample ELF kernel with FASM and Tiny C Compiler (aka TCC).
FASM is, for me, the best assembler that exists. TCC is a small and fast C compiler, which produces x86, x86_64 or ARM code, and generates PE and ELF executables. TCC is heading torward full ISOC99 compliance, and can compile itself, like FASM.

http://wiki.osdev.org/Fasm-TCC_BareBones

Re: Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 8:40 am
by Combuster
From what I gather, you get a binary meant to loaded to 0x1000:0000. Which means you need a custom bootloader - what did you have in mind for that?

Re: Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 9:15 am
by f2
Combuster wrote:From what I gather, you get a binary meant to loaded to 0x1000:0000. Which means you need a custom bootloader - what did you have in mind for that?
TCC isn't able to produce binary executables. So, I have made some changes in my article. It describe how to make a
sample kernel that can be booted by Grub. I tested this tutorial, it works fine under Linux because the Win32 version
of TCC cannot make ELF executables (only object files). Under Windows, you need to recompile TCC without PE support.

Re: Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 10:30 am
by Troy Martin
Damn, I was hoping this was FASM/Turbo C :) now THAT would appease the noobs!

But good tutorial anyways!

Re: Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 10:35 am
by f2
Troy Martin wrote:Turbo C :)
Indeed, this is not Turbo C, but Tiny C Compiler or "TinyCC".
That's true that "TCC" means "Turbo C" for someone. TinyCC and produce x86, x86_64 and ARM code.

Otherwise, Fasm & TCC are a good choice. GCC is large, slow, and generates poor code.
On the over hand, TCC is small and fast. But the code isn't the most optimized.
I have no criticisms for Nasm.

Re: Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 6:13 pm
by AndrewAPrice
Tommy wrote:Otherwise, Fasm & TCC are a good choice. GCC is large, slow, and generates poor code.
Excuse me and define "poor"? Please citate or show proof.
Tommy wrote:On the over hand, TCC is small and fast. But the code isn't the most optimized.
So in your case neither compilers generate 'good' code.

Re: Fasm/TCC BareBones

Posted: Sat Aug 22, 2009 7:37 pm
by earlz
Tommy wrote:
Troy Martin wrote:Turbo C :)
Indeed, this is not Turbo C, but Tiny C Compiler or "TinyCC".
That's true that "TCC" means "Turbo C" for someone. TinyCC and produce x86, x86_64 and ARM code.

Otherwise, Fasm & TCC are a good choice. GCC is large, slow, and generates poor code.
On the over hand, TCC is small and fast. But the code isn't the most optimized.
I have no criticisms for Nasm.
TCC? GCC is large and slow(as a compiler) but its code generation is where it wins because of its absolutely huge code base and number of patches through the years(or is it decades now) for optimization. Now, TCC isn't even C99 compatible yet, which means its a fairly new project(I really do not know though) and FASM? You know that doesn't work on anything but DOS, Windows, and Linux right? That leaves out BSDs and most likely your OS-to-be without a porting effort involving patching. (there is no standard library for assembly)

If your just looking for another compiler to use instead of GCC, look at PCC.(BSD C compiler) which has only like 3 things missing for C99 compatibility and produces reasonable code for the x86 (most other targets are slightly broken, as this project was just recently revived, though it existed before GCC)

Re: Fasm/TCC BareBones

Posted: Sun Aug 23, 2009 2:15 am
by f2
MessiahAndrw wrote:
Tommy wrote:Otherwise, Fasm & TCC are a good choice. GCC is large, slow, and generates poor code.
Excuse me and define "poor"? Please citate or show proof.
This is not me who is behind these criticisms: http://en.wikipedia.org/wiki/GNU_Compil ... ternatives.
MessiahAndrw wrote:
Tommy wrote:On the over hand, TCC is small and fast. But the code isn't the most optimized.
So in your case neither compilers generate 'good' code.
I didn't say that. The purpose of this article is not to say that TCC is the best, but to show that we can make an OS with other
compilers than GCC. Here are all features of TCC:
> TCC compiles C code about 9 times faster than GCC.
> TCC generates averagely optimized x86 code.
> TCC supports the ISO C99 standard (even if this support is not as complete as PCC).
> Under Linux, TCC can be used as a C interpreter (just add '#!/usr/local/bin/tcc -run' at the first line of your C source, and execute it directly from the command line).
> TCC has few dependencies. Only libc is required for its compilation.
> TCC includes a linker and an assembler (for x86 only).

Re: Fasm/TCC BareBones

Posted: Sun Aug 23, 2009 3:43 am
by fronty
GCC doesn't completely implement C99. There still is few missing features.

Re: Fasm/TCC BareBones

Posted: Fri Jul 27, 2012 1:09 pm
by Tarkin
Hey!!! I guess solar deleted the page, is there any way it can be brought back??? Perhaps tucked away in a corner somewhere?

I would argue that fasm is different enough from nasm! I modified the code under the nasm barebones, just enough to get it to assemble, and it has a different length than the nasm one!

I often wander to/away from OS dev'ing, and I have always used the FASM/TCC barebones to 'brush up', and get back into it.

Is there an archived version anywhere?

TTFN,
Tarkin

Re: Fasm/TCC BareBones

Posted: Fri Jul 27, 2012 6:15 pm
by Combuster
The meaningful differences with the regular barebones were so minimal that the FASM/TCC tutorial was basically a more broken version of the other. You should only need to change the assembler dialect.

The non-tutorial content and revision history can be found under the TCC page.