OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 9:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 7:46 am 
Offline
Member
Member
User avatar

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

_________________
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa


Last edited by f2 on Sat Aug 22, 2009 10:18 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 8:40 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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 ]


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 9:15 am 
Offline
Member
Member
User avatar

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


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 10:30 am 
Offline
Member
Member
User avatar

Joined: Fri Apr 18, 2008 4:40 pm
Posts: 1686
Location: Langley, Vancouver, BC, Canada
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


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 10:35 am 
Offline
Member
Member
User avatar

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


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 6:13 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
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.


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sat Aug 22, 2009 7:37 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
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)

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sun Aug 23, 2009 2:15 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 15, 2009 10:01 am
Posts: 311
Location: France
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_Compiler_Collection#Possible_future_alternatives.

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


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Sun Aug 23, 2009 3:43 am 
Offline
Member
Member

Joined: Mon Jan 14, 2008 5:53 am
Posts: 188
Location: Helsinki
GCC doesn't completely implement C99. There still is few missing features.


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Fri Jul 27, 2012 1:09 pm 
Offline

Joined: Sat Jun 27, 2009 8:15 am
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Fasm/TCC BareBones
PostPosted: Fri Jul 27, 2012 6:15 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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 ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group