flat assembler
Message board for the users of flat assembler.

Index > OS Construction > A binary choice...

Author
Thread Post new topic Reply to topic
Giedrius



Joined: 13 Feb 2005
Posts: 40
Location: Lithuania
Giedrius
I can't decide whether to program my kernel in ANSI C or asm. What would you suggest? I have way bigger experience in C, but asm has some good stuff too.

_________________
Better to rule in hell, than to be a slave in heaven...
Post 24 Feb 2005, 13:29
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Well, this forum is not very suitable place to ask such questions... Wink
My opinion is: "Not simply assembler - FASM".
Why:
1. There are only few assemblers that can be used for OS developement.
gas - the syntax is too strange for almost everyone, but Linux wizards.
NASM - too slow. It is not smart to bind whole your OS to such assembler.
FASM - clean syntax, lightning fast compilation even on very big sources. highly portable - you will be able to make your OS self-dependent at very early stage of developement.

About C - what to say... if it have to be HLL, beter use PHP. Wink

Regards.
Post 24 Feb 2005, 13:57
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn
I use asm for the kernel and I hope to use C for the rest of the system. But this is only good if you want to write a microkernel. Because for a monolithkernel it would be better to do all the work in one language!
Post 24 Feb 2005, 15:41
View user's profile Send private message Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu
maybe you should say also the other part Wink most problem is (bigger for beginners, smaller for good coders) that actually most code you'll find in the internet is written for NASM. so at the beginning it's not clever i think to learn more syntaxes and to port every code from NASM to FASM and so on. i think first you should use NASM and if you can code bether you can choice FASM, too, so you can port everything when you understand it and you can optimize it the same time...
Post 24 Feb 2005, 15:42
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
I suppose it really depends on how fast you wish to develop your system or how fast you want your code to be. From the development standpoint it will be very benificial to write in C if speed of devlopment is a key goal. However, from the sheer speed of running your OS, assembly is an order of magnitude faster (at the clock tick level) than C. Other aspects include library support; C will require you to create your library according to your OS design, ASM you will not have to as you're writting specifically for the processor and not specifically the OS (a layer of abstraction has been removed), that is until you want applications to work within your OS, then they have to interact with your API. Integrated Development Environment and Debuging; neither one has either initially, so it might be a moot point, though there are IDEs and DEBUGs written in assembly with there sources available and are very portable (relatively speaking) to your new OS, C on the other hand requires you to have that library already written, as above.
Post 24 Feb 2005, 16:28
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
It really depends on what you feel comfortable with, I guess. Unless you want to support very old hardware *or* you are a bad C programmer *or* you are using a bad compiler, there shouldn't really be runtime (size/speed) problems with using C for the kernel.

Proper design (including algorithms and memory organization) is a lot more important than choosing between C/Asm.

My first kernel was written entirely in asm. After I had implemented a keyboard handler with codepage support and basic paging and some task-switching, I abandoned the project for some years.

During those years, my experience with various things have increased, and compilers have become a lot better. I've moved from the "OMFG! Everything must be written in assembly" attitude to "assembly where it makes sense / where it matters".

I recently got interested in os-dev again, and now my kernel is written in a mix of (F)ASM and C. I'm using VC2003 to compile, since it's one of the best out there, and it's free (and even the free vc2003 toolkit license is a lot less restrictive than the MASM license, it actually allows things like osdev!).

But well, it's a personal choice Smile
Post 24 Feb 2005, 16:54
View user's profile Send private message Visit poster's website Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn
My problem is that I cannot "think" in C but in ASM Wink So my ASM code works and my C doesn´t Sad I also think that a ASM kernel is simplier to debug than a C kernel, because you know what you´ve written and what it should do (when you debug with Bochs this will help you).
Post 24 Feb 2005, 18:00
View user's profile Send private message Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio
JohnFound wrote:
1. There are only few assemblers that can be used for OS developement.

gas,NASM,FASM,octasm,a386(not free),tasm and others.
thats a lot compared to the HLL that can be used for OS developement.
Of course all languages can be used with a little help from assembly.
Post 24 Feb 2005, 19:47
View user's profile Send private message Visit poster's website Reply with quote
wishmaster



Joined: 25 Aug 2004
Posts: 9
wishmaster
Hello !

f0dder wrote:

I'm using VC2003 to compile


Could you explain me how to use VC2003 for osdev ? How to link to flat binary ?

Thx
Post 26 Feb 2005, 17:07
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
I don't link to a flat binary, I actually have PE support in my bootloader. The code required for loading a PE at boottime (ie, not supporting all the stuff a PE can do) is very simple, and it's pretty nice to have your kernel in a standard format.

My old kernel was in flat binary format, back then I used NASM and DJGPP (32bit dos extended port og GCC).
Post 27 Feb 2005, 18:18
View user's profile Send private message Visit poster's website Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach
I suggest that you use the language that your good at.
Post 28 Feb 2005, 11:37
View user's profile Send private message Reply with quote
wishmaster



Joined: 25 Aug 2004
Posts: 9
wishmaster
I am using GRUB as bootloader. Is GRUB able to load PE files ? If not is it possible to add the multiboot header to a PE file made with VC2003 ?
Post 01 Mar 2005, 14:06
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Hmmm, never really fancied grub... but it should be possible to write either a multiboot header (haven't researched those), or write a small PE loader, prepend it to the PE kernel, and have grub load+execute as binary...
Post 01 Mar 2005, 20:59
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
just a legal question does the EULA of VC2k3 allow wrting OSes? (iirc MASMs EULA forbids it) - I don't have access (nor want to for that matter, but that's OT) VC2k3 so I can't check this...
Post 07 Mar 2005, 09:13
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Yes it does, scientica - of course the version with visual studio.net does (like the commercial MASM license), but even the VC2003 toolkit license allows it - it's very unrestricted. And it's one of the best compilers around, so it's quite suitable Smile
Post 07 Mar 2005, 11:38
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.