Kernel in assembly

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Haghiri75
Member
Member
Posts: 29
Joined: Fri Nov 16, 2012 4:16 am
Location: Iran
Contact:

Kernel in assembly

Post by Haghiri75 »

Greetings.

I have experience of writing boot sector in assembly, and also kernel in C.

But for now, I'm curious about writing a kernel in assembly and boot it using GRUB (for x86-based computer).

What shall I read and where shall I start?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Kernel in assembly

Post by iansjack »

If you can already do it in C, then just do the same in assembler. As for Grub, just read about the Multiboot standard.
Last edited by iansjack on Fri Apr 22, 2016 2:10 am, edited 1 time in total.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Kernel in assembly

Post by onlyonemac »

If you've written a kernel in C, then you should already have a good idea of:
  • what design of kernel you like and how this works (e.g. microkernel, monolithic kernel, etc.)
  • what functions the kernel needs to perform (e.g. memory management, thread management, etc.)
  • what algorithms you use to implement these functions and how these work (e.g. bitmap memory allocator, round-robin scheduler, etc.)
  • how to work the various hardware in the computer (e.g. getting keyboard input, writing to disk, enumerating PCI devices, etc.)
In that case, you should get a solid understanding assembler before you try to implement similar ideas to what you used in your C kernel in assembler. It shouldn't be too difficult to do this though once you've got a good understanding of assembler, because you already know what you're trying to do from an operating system development point of view.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Haghiri75
Member
Member
Posts: 29
Joined: Fri Nov 16, 2012 4:16 am
Location: Iran
Contact:

Re: Kernel in assembly

Post by Haghiri75 »

OK, I found a book about writing simple OS a long time ago. It has some information about entering protected mode.
Is that enough?
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Kernel in assembly

Post by Octocontrabass »

If you use Grub, you don't need to enter protected mode. Grub will do it for you. You should read the Multiboot Specification.

Why do you want to write your kernel in assembly?
Haghiri75
Member
Member
Posts: 29
Joined: Fri Nov 16, 2012 4:16 am
Location: Iran
Contact:

Re: Kernel in assembly

Post by Haghiri75 »

Octocontrabass wrote:If you use Grub, you don't need to enter protected mode. Grub will do it for you. You should read the Multiboot Specification.

Why do you want to write your kernel in assembly?
I think it's more fun to write whole kernel in assembly. Is there any kernel(s) in assembly except MikeOS?
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Kernel in assembly

Post by onlyonemac »

Haghiri75 wrote:I think it's more fun to write whole kernel in assembly. Is there any kernel(s) in assembly except MikeOS?
MenuetOS

But for someone who "has experience of writing a kernel in C" you're starting to sound a bit ignorant.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Kernel in assembly

Post by BrightLight »

My OS is written entirely in assembly language. I don't use GRUB, though. But booting a kernel with GRUB in assembly or C is just the same.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Haghiri75
Member
Member
Posts: 29
Joined: Fri Nov 16, 2012 4:16 am
Location: Iran
Contact:

Re: Kernel in assembly

Post by Haghiri75 »

onlyonemac wrote:
Haghiri75 wrote:I think it's more fun to write whole kernel in assembly. Is there any kernel(s) in assembly except MikeOS?
MenuetOS

But for someone who "has experience of writing a kernel in C" you're starting to sound a bit ignorant.

I just wrote a simple "Hello World" kernel in C, because I was curious about that. But now, I want to move that code to assembly, and have more fun and experience and knowledge :D
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: Kernel in assembly

Post by Techel »

Yeah, writing assembly is fun, but if you plan to expand your project, highlevel languages like C and C++ are more suitable.
rdos
Member
Member
Posts: 3303
Joined: Wed Oct 01, 2008 1:55 pm

Re: Kernel in assembly

Post by rdos »

Haghiri75 wrote:
Octocontrabass wrote:If you use Grub, you don't need to enter protected mode. Grub will do it for you. You should read the Multiboot Specification.

Why do you want to write your kernel in assembly?
I think it's more fun to write whole kernel in assembly. Is there any kernel(s) in assembly except MikeOS?
Yes. Most of RDOS is still in assembly. There are a few new drivers in C, but that's mostly for non-time critical things like ACPI, figuring out audio connections and also the code that moves threads between cores.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Kernel in assembly

Post by osdever »

Haghiri75 wrote:
Octocontrabass wrote:If you use Grub, you don't need to enter protected mode. Grub will do it for you. You should read the Multiboot Specification.

Why do you want to write your kernel in assembly?
I think it's more fun to write whole kernel in assembly. Is there any kernel(s) in assembly except MikeOS?
ExDOS by omarx024 is written fully on Assembly. Also I know Russian operating syste, names GkukOS.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
CorruptedByCPU
Member
Member
Posts: 79
Joined: Tue Feb 11, 2014 4:59 pm

Re: Kernel in assembly

Post by CorruptedByCPU »

From: https://github.com/akasei/Cyjon.
Only assembly language, using own Bootloader(Omega) or GRUB (Multiboot v1).
Every label is in English, but comments in Polish.
Look at this: Imagehttp://wataha.net/shot/4.png
Last edited by CorruptedByCPU on Sun Apr 24, 2016 6:59 am, edited 1 time in total.
https://blackdev.org/ - system programming, my own 64 bit kernel and software.
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Kernel in assembly

Post by Nable »

catnikita255 wrote:ExDOS by omarx024 is written fully on Assembly. Also I know Russian operating system, names GkukOS.
I'm surprised a bit that nobody has mentioned KolibriOS.
Post Reply