Fasm/TCC BareBones

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
User avatar
f2
Member
Member
Posts: 311
Joined: Mon Jun 15, 2009 10:01 am
Location: France

Fasm/TCC BareBones

Post 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
Last edited by f2 on Sat Aug 22, 2009 10:18 am, edited 1 time in total.
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa
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: Fasm/TCC BareBones

Post 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?
"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
f2
Member
Member
Posts: 311
Joined: Mon Jun 15, 2009 10:01 am
Location: France

Re: Fasm/TCC BareBones

Post 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.
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Fasm/TCC BareBones

Post by Troy Martin »

Damn, I was hoping this was FASM/Turbo C :) now THAT would appease the noobs!

But good tutorial anyways!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
f2
Member
Member
Posts: 311
Joined: Mon Jun 15, 2009 10:01 am
Location: France

Re: Fasm/TCC BareBones

Post 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.
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa
User avatar
AndrewAPrice
Member
Member
Posts: 2300
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Fasm/TCC BareBones

Post 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.
My OS is Perception.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: Fasm/TCC BareBones

Post 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)
User avatar
f2
Member
Member
Posts: 311
Joined: Mon Jun 15, 2009 10:01 am
Location: France

Re: Fasm/TCC BareBones

Post 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).
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: Fasm/TCC BareBones

Post by fronty »

GCC doesn't completely implement C99. There still is few missing features.
Tarkin
Posts: 3
Joined: Sat Jun 27, 2009 8:15 am

Re: Fasm/TCC BareBones

Post 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
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: Fasm/TCC BareBones

Post 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.
"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 ]
Post Reply