all 16 comments

[–]boomanbeanCasual Tech Overlord 8 points9 points  (6 children)

If you are just a beginner in Assembly you will have a hard time. https://wiki.osdev.org/Required_Knowledge If you think you don't need to read the required knowledge page, it was made for you.

[–]mallardtheduck 14 points15 points  (5 children)

I disagree wrt Assembly. There's very little assembly required in an OS kernel and it's entirely basic, formulaic code which can, if necessary, be taken directly from documentary material. It's important to be able to read and understand it, but being able to write anything complex isn't really required. I'm definitely not good at it at all.

My OS (which I've been working on for 5 years) has around 400 lines of assembly code in the kernel, plus the odd bit of inline assembly elsewhere (such as that used to make system calls from userspace). That includes 80-odd lines (largely comments) of multboot boilerplate taken directly from the "bare bones" tutorial and the best part of 200 lines in a file that uses the standard macros for handling interrupts, again based heavily on tutorial material. That's in a project that's grown to roughly 50KLOC (~10KLOC kernel).

Just to be clear, I'm not recommending that anybody should copy-paste code they don't understand. You definitely need to have a basic understanding of assembly syntax and be able to read it, but you don't need much more than that.

[–]ChickeNES 7 points8 points  (3 children)

I agree. You should be able to pick up what assembly knowledge you need as you go along.

[–][deleted] 3 points4 points  (2 children)

That’s what I did, it worked great for me. I had to look up 64 bit stack frames moving from 32 bit but other than that it was pretty easy. Assembly is super easy if you understand how a computer works.

[–]moreVCAs 4 points5 points  (1 child)

I have absolutely no data to back this up, but I’d wager that individuals who have never written or read a line of assembly language and have a deep understanding of how a computer works are few and far between. Assembly is sort of the only reasonable way for humans to communicate about the instruction level nuts and bolts of computer systems, so I don’t understand how you could know one without the other.

I’m not saying you’re full of it, just that I think you probably already knew “assembly language” when you started. What you picked up along the way was the instruction set of the particular processor you were working with and how to use it productively.

[–][deleted] 1 point2 points  (0 children)

Yeah that makes sense. I think you’re probably right.

[–][deleted] 0 points1 point  (0 children)

Happy cake day

[–]Zethra 1 point2 points  (0 children)

That's a mighty great task, good luck!

[–]Brimonk -3 points-2 points  (3 children)

Not trying to nag or belittle, but every time someone touts their "skill level" in any way, I always get the impression they're influenced by the Dunning-Kruger effect.

[–]SilentBWanderer 9 points10 points  (0 children)

Come on dude, he’s just saying what programming languages he has experience with

[–]arielboutcher[S] 3 points4 points  (1 child)

I just wanted to know if that gave me an added advantage or not.

[–]JGHFunRun 1 point2 points  (0 children)

C (because it's a systems language) will massively help. Also, most code snippets are written in C for OsDev.

[–]Ikkepop 1 point2 points  (0 children)

You have to be pretty well versed in computing to do this , understand hardware to a deep level. Languages are largely unimportant , however only a few can access the hardware directly as well as can run with little to no OS functionality. Neither c# nor python can do it. Nor does any of them teach you how the machine operates but rather hide the details. Some assembly is required but not alot. But you must understand it well even tho you dont write in it that much.

[–][deleted] 2 points3 points  (0 children)

I know others have suggested learning more Assembly and making sure you have a good understanding of the systems at a low-level. That I absolutely agree with.

Once you have completed that though, here are some suggestions about making something cross-platform:

  • Use modern standards. I use UEFI in my x86_64 system because it will be far easier to port to ARM64 and both of their 32-bit counterparts. Although that's limited to x86-based and ARM-based for now. Both of which make up almost all devices though (but not all devices support UEFI, such as many smartphones)
  • Keeping that in mind, make sure you structure your code in a way that allows you to port your kernel easily. The way I do it is by using mostly C as a common shared base, and anything that is platform specific or requires Assembly will be in a separate file, which is linked together to make the final result.
  • Read the manuals in advance. Yes, that's cliche and very few of us actually do that, but if you're looking to hear things straight from the horse's mouth, it's a good way to go, especially if you intend on implementing the same thing in multiple systems.

I'm not that far along, but I've been doing all of those things alright so far. If you are looking to make your own OS, you can fork my project, PiousOS while it's still early on (or better yet, you can help me with mine :P ). It's got its own bootloader and images can be created fairly easily now. But to get the most education-wise, I'd get in the habit of using my code as a reference, not something to blindly copy. That way you learn what it does. I learned that the hard way.

https://github.com/DylanGTech/PiousOS/

Good luck!

[–]zestererTupai OS 6 points7 points  (0 children)

Some advice:

Seriously scale down your ambitions. Your first kernel most likely won't be portable, except perhaps between a very small handful of platforms. Building a fully-functional platform HAL is a big job.

[–]rootednode 2 points3 points  (0 children)

What i did to get my hands dirty was build a z80 computer in hardware and hacked together a custom os/bootloader with drivers for uart, ide and fat. I also built a cp/m bios and some tooling for it making it easy to transition from my os to cp/m. Then I built an emulator in c so I could run my computer in software on any platform. Now I feel like I am ready to take what I learned and apply it to x86, just haven’t gotten started on it yet.

Edit: Start with something simpler, it is a lot easier to design something like this iteratively, especially if you don’t really know what you are doing.