flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Which language for OS dev: Assembly or C?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 28 Sep 2011, 14:28
Hello, again. I already started studying OS design to get a basis of what it's all about, and a thought came across my head: "really, what language to use?"

I want to know which language is best for developing an OS, because I love assembly and it seems okay for OS development, but it's hard to work with, and its low-level and is best for implementing a kernel; whereas C, which was designed for system development, is easier to program in, BTW i am sort of new to C. I am unsure of which language is best. Which is better?


Thanks in advance.

_________________
meshnix
Post 28 Sep 2011, 14:28
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 28 Sep 2011, 18:03
Hi
If you like the assemby , is very difficult to digest other languages​​ Confused , the assembly is not a language, are the instructions on the various processors.
However, it is also important to know C, not to program, but to understand the high-level languages​​.
many of these languages ​​are based on C (Java, C + +,and so on) Wink

_________________
Nil Volentibus Arduum Razz
Post 28 Sep 2011, 18:03
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 28 Sep 2011, 18:31
It depends on your design and goals but unless you're really aiming to support architectures other than x86 it's mostly down to your preference. You also have the option of mixing asm and C, which for FASM I found quite easy to do (though I've not used it in an OS development context).
Post 28 Sep 2011, 18:31
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 28 Sep 2011, 19:08
Personally I did assembly and (a subset of) C++ when I played with osdev.

What to choose depends on project goals as well as personal preference. You're not going to come up with the next linux, so choose what you feel is fun Smile
Post 28 Sep 2011, 19:08
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 28 Sep 2011, 22:47
Thanks for the replies!

DJ Mauretto
DJ Mauretto wrote:
If you like the assemby , is very difficult to digest other languages​​ , the assembly is not a language, are the instructions on the various processors.
However, it is also important to know C, not to program, but to understand the high-level languages​​.

I do like assembly, although it's difficult, it will have to work. I find assembly to be very versatile with the instructions, control, and manipulation. I think I will go with it.

It is important. High-level languages (3G & 4G) are what most programmers are using today in software engineering because of the fast-paced production of applications, so that's understandable.

cod3b453
cod3b453 wrote:
It depends on your design and goals but unless you're really aiming to support architectures other than x86 it's mostly down to your preference. You also have the option of mixing asm and C
The aim SHOULD support x86 but WOULD support other architectures, but multi-architecture is not the aim right now.

Can FASM assembly syntax be used as the inline assembly syntax?

f0dder
f0dder wrote:
Personally I did assembly and (a subset of) C++ when I played with osdev.

What to choose depends on project goals as well as personal preference. You're not going to come up with the next linux, so choose what you feel is fun Smile

How far did you expect or intend that you project would reach or go (respectively)?

Were assembly and C++ used together?

And that's true. It's not the next linux, of course lol. However, I hope to learn alot from this project--something maybe similar to DexOS.

The project goals are to develop a general-purpose operating system and to learn about OS development. In addition, design and implement a small assembler. All just for fun!
Post 28 Sep 2011, 22:47
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 28 Sep 2011, 23:44
Well,....You would use C as tools, the interpreter. and ASM as the interpreted overall language.

IE, Say MS Visual Studio is an OS IDE that creates ASM OS code.

That simple...
Post 28 Sep 2011, 23:44
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 29 Sep 2011, 07:11
adroit wrote:
Thanks for the replies!
...The aim SHOULD support x86 but WOULD support other architectures, but multi-architecture is not the aim right now.

Can FASM assembly syntax be used as the inline assembly syntax?
...
For portability across architectures you'll want to minimise the amount of asm you use or at least have a well-defined interface between asm and C so you can swap out the asm parts for different architectures.

I don't think there are any C compilers that support FASM syntax but you can create C-linkable objects from FASM and link that with your C code.
Post 29 Sep 2011, 07:11
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 29 Sep 2011, 16:34
adroit wrote:
What to choose depends on project goals as well as personal preference. You're not going to come up with the next linux, so choose what you feel is fun Smile

How far did you expect or intend that you project would reach or go (respectively)?[/quote]I didn't have any plan with the kernel other than learning more about system-level x86. Iirc the last time I touched it was around 2002, where (as far as I recall) I had:
1) multi-stage bootloader, including being bootable via TFTP on bootrom from an intel NIC (that was mostly an issue of setting up 3rd party code, I didn't write all the tooling code Smile).
2) serial cable bootloader, written by myself - never got it entirely stable at high speeds, couldn't be arsed for after I got network boot setup Smile
3) keyboard and timer IRQ handling, including scancode->charbuffer and rudimentary timer/task support.
4) rudimentary paging and memory allocation support.

Mostly pretty trivial stuff, the most interesting thing about the kernel is probably that it started out as a raw image, requiring custom gnu linker scripts etc... but was later moved to a Visual Studio build environment producing PE .exe output.

And then I kinda lost interest Smile

adroit wrote:
Were assembly and C++ used together?
Yes. The first-stage bootloader was entirely assembly, 2nd-stage was mostly assembly, and the kernel itself a mix of assembly and C++. And again, a pretty limited subset of C++; I wouldn't even consider using C++ style exceptions at kernel level (too compiler+library dependant, and not really the right way to handle things at kernel level anyway IMHO). But being able to use RAII is very nice.

_________________
Image - carpe noctem
Post 29 Sep 2011, 16:34
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 07 Oct 2011, 18:11
I think it is all up to you. In order to code an OS though, you have to learn an abundance of things. You're on your way, and once you feel comfortable, you'll know what to use when you start to code.
Post 07 Oct 2011, 18:11
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 10 Oct 2011, 23:06
Thanks guys.

I think I might do the OS mainly in assembly, since I'm trying to improve on in the assembly language. Another thing that deterred me is that I'll have to use linkers. I'd rather keep my learning process simple.

@f0dder | smiddy
- [Nice outline; I just might use it]. This is a lot to learn, indeed. Do you have a link to these sources, or do you just keep them as a personal code? I'd really like to understand keyboard and memory management much better. Although they are trivial, they are enormous to undertake for first-timers.
- Currently, I am analysing, specifying, and designing the OS. I am learning about operating systems as much as possible before coding. I plan to keep notes of what I learnt for later, rather than relying on mental notation. MS-OneNote is really good for that.

_________________
meshnix
Post 10 Oct 2011, 23:06
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 10 Oct 2011, 23:48
ASM is a great language, but is not portable.
It will take 10 man years to make good OS
but the x86 may disappear in this time?

My advice, as my OS project follows:

Use ASM only for whats needed, boot, setup, etc...
Then pass control to a C kernel which can be portable.

So if x86 dies (like 8080 did) the project is still viable.

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 10 Oct 2011, 23:48
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 11 Oct 2011, 18:31
androit wrote:
[Nice outline; I just might use it]. This is a lot to learn, indeed. Do you have a link to these sources, or do you just keep them as a personal code? I'd really like to understand keyboard and memory management much better. Although they are trivial, they are enormous to undertake for first-timers.
I don't know if I still have the source lying around anywhere, this was from before I got into version control managent systems Smile

Keyboard handling is - mostly - trivial, but it does require building tables and thinking how you want to handle accents and stuff. Memory handling is not trivial, although you can cobble something that "works okayish" together in a couple of hours Smile

androit wrote:
Currently, I am analysing, specifying, and designing the OS. I am learning about operating systems as much as possible before coding. I plan to keep notes of what I learnt for later, rather than relying on mental notation. MS-OneNote is really good for that.
Try not to overspecify, or you'll end up with a nice überkernel.one file, and no code.

You can do osdev in a rather modular fashion, so you can do a fair amount of research on one piece of the system, play around with implementations of it, and refine the process while researching more, and sketching out other parts of the system.

It's probably a good idea to start with a rough outline of what you want to achieve, though.
Post 11 Oct 2011, 18:31
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 14 Oct 2011, 17:31
There are quite a few references here: http://wiki.osdev.org/Main_Page to start with.
Post 14 Oct 2011, 17:31
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 15 Oct 2011, 21:07
@bitshifter
I might use C for this first project, and then assembly on a smaller OS project (i.e. an experiment). The x86 might since they are up to i786 now. (I don't know though).


@f0dder
My mistake in saying MM is trivial.

Sad. I'll try searching the internet for some demos. Dex4u had some demos on his site, but it was taken down.

I'll try not to. But I learnt that it's best to design efficiently, and implement bug-freely—or something like that.

Thanks for the tip. I'll try that.


@smiddy
Thanks. Because the project was suppose to be done in assembly, I never thoroughly referred to OSDev.org. I also found another site before: www.brokenthorn.com.
Post 15 Oct 2011, 21:07
View user's profile Send private message Reply with quote
addes3



Joined: 09 May 2011
Posts: 29
addes3 15 Oct 2011, 22:01
I wouldn't use C just because you want to be compatible with different processors.
For large, commercial OS's this may be essential, but for a small hobby OS, who cares.
I seriously doubt that the x86 is going to disappear anytime soon, so if you like Assembly, use Assembly.
Post 15 Oct 2011, 22:01
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 30 Nov 2011, 13:27
Agreed. As this is an experiment, assembly language could be used.

My plan is to develop a research OS using assembly language to learn about the operating system at basic.

Thank you guys.
Post 30 Nov 2011, 13:27
View user's profile Send private message Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville 01 Dec 2011, 00:37
If you want to develop an OS for a particular CPU platform then pure assembly is the way to go because it gives you the maximum ability to control what the processor actually does while booting and running your OS.

_________________
FAMOS - the first memory operating system
Post 01 Dec 2011, 00:37
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 01 Dec 2011, 17:48
Theres also a ARM ver of DexOS written with FasmArm, due out soon.
So ASM hobby OS's can be ported to other processors.
Post 01 Dec 2011, 17:48
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 01 Dec 2011, 18:12
Dex4u wrote:
Theres also a ARM ver of DexOS written with FasmArm, due out soon.
So ASM hobby OS's can be ported to other processors.
Ported by rewriting everything, or ported by keeping large oarts of the codebase entirely the same? Smile

_________________
Image - carpe noctem
Post 01 Dec 2011, 18:12
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 01 Dec 2011, 18:28
f0dder wrote:
Dex4u wrote:
Theres also a ARM ver of DexOS written with FasmArm, due out soon.
So ASM hobby OS's can be ported to other processors.
Ported by rewriting everything, or ported by keeping large oarts of the codebase entirely the same? Smile


Rewriting, but with the road map there and the knowledge from coding it the first time.
It took 6 months, instead of 8 years the first time.
I believe its better to rewrite anyway to take advantage of the new processor function.
Post 01 Dec 2011, 18:28
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.