Writing Os entirely in assembly
-
- Posts: 16
- Joined: Mon Jan 26, 2015 2:56 am
Writing Os entirely in assembly
Like title says, has anyone here done this? What are your feedback?
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: Writing Os entirely in assembly
I write my OS entirely in assembly, and I think it is great.
I don't know other languages well, TBH. But I'm not even willing to learn C/C++; I'm very comfortable with assembly.
Pros:
- Smaller size files.
- (Probably) faster execution.
- More control over what goes on behind the scenes.
Cons:
- Not portable.
- Gets cluttered and unreadable with time.
I don't know other languages well, TBH. But I'm not even willing to learn C/C++; I'm very comfortable with assembly.
Pros:
- Smaller size files.
- (Probably) faster execution.
- More control over what goes on behind the scenes.
Cons:
- Not portable.
- Gets cluttered and unreadable with time.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: Writing Os entirely in assembly
I did and do write; though, the OS is not quite public yet. Well, it's just a tiny OS and lacks very basic features (yet), but it has a text-editor, FASM port, and 2048-like game--everything in an assembly language. Just drop me a PM, if you're interested.
(I'm not advertising anything here; the whole project is free and in public domain.)
Just as Omar, Assembly is the only language that I know good. Disadvantages are (1) Assembly is complex, though not hard (2) "real" OSDev'ers would hate you.
(I'm not advertising anything here; the whole project is free and in public domain.)
Just as Omar, Assembly is the only language that I know good. Disadvantages are (1) Assembly is complex, though not hard (2) "real" OSDev'ers would hate you.
Last edited by Muazzam on Fri Aug 28, 2015 2:32 am, edited 1 time in total.
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Writing Os entirely in assembly
I write in assembly because I want to control exactly what instructions the CPU is executing. I want to be able to say that the CPU is running only what I have written, not some compiler's interpretation of what I have written.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Re: Writing Os entirely in assembly
I believe that trying to write an OS entirely in assembly is a classic beginner's mistake which most (eventually) grow out of. The advantages of using a high-level language are overwhelming; the advantages of assembly are overrated (and mostly wrong).
But don't worry - even some of the pioneers made this mistake (until they had written a suitable language).
But don't worry - even some of the pioneers made this mistake (until they had written a suitable language).
Re: Writing Os entirely in assembly
You sound like someone speaking language X not good enough and blaming someone speaking that language natively for not properly understanding you.onlyonemac wrote:not some compiler's interpretation of what I have written.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Writing Os entirely in assembly
Maybe because of all flavours of braces failing on braille displays?
Re: Writing Os entirely in assembly
I think I'll write an operating system entirely in microcode. That way I'll be sure that the processor is doing exactly what I want it to.
Re: Writing Os entirely in assembly
I actually considered this, until I learned that Intel doesn't allow you to update their microcode.iansjack wrote:I think I'll write an operating system entirely in microcode. That way I'll be sure that the processor is doing exactly what I want it to.
But if it weren't for that, I probably would have tried it.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Writing Os entirely in assembly
Actually I don't have a braille display. But while C code is a pain to listen to with a screenreader, assembler is even more painful. Opcode mnemonics get slurred into their operands and unless you kind of know what you're expecting to hear you're going to be spending a lot of time pressing the arrow keys to read each line character-by-character. And you can show a brace character on a braille display but it's not easy to read, no, because it involves multiple braille characters in a row. But then, listening to C code without headphones generally just leads to my mother saying "why does it keep saying 'rat race'?" when she mis-hears "right brace" as "rat race" and refuses to shut up when I tell her to!Combuster wrote:Maybe because of all flavours of braces failing on braille displays?
I assume you would have acquired an adequate stockpile of CPUs, as it is rather easy to brick them by damaging the microcode.SpyderTL wrote:I actually considered this, until I learned that Intel doesn't allow you to update their microcode.
But if it weren't for that, I probably would have tried it.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Re: Writing Os entirely in assembly
Are you sure? I don't think microcode updates are persistent, so shouldn't a simple power cycle fix things?onlyonemac wrote:I assume you would have acquired an adequate stockpile of CPUs, as it is rather easy to brick them by damaging the microcode.
Re: Writing Os entirely in assembly
I wrote a smallish OS in assembly before moving on.
http://ready4dis.8m.com/cgi-bin/i/PhatO ... 271105.JPG
32-bit, preemptive multitasking, virtual memory manager, keyboard, mouse, hdd, fdd, file system (fat), supported VESA (VBE). It wasn't to bad to write, came out to like 12kb total. With the font set and graphics it was a whopping 24kb. The GUI was written in C, the OS written in assembly. While it was a great learning experience, which is the reason I did it in the first place, I re-wrote it in C as I originally planned. I don't have any benchmarks, but I doubt the asm version is any faster in reality, and the fact that it's much easier (for me) to implement more advanced algorithms in C, the C version probably ended up faster in general due to a better design, and it's much easier to extend or use on other hardware. Of course, the C version ended up being much larger, but it also ended up with many more features (virtual file system, vs individual file systems, a better task scheduler, a command line as well as GUI, SMP, and 64-bit is working, but not done...). Could I write it all in asm, yes. Do I want to? No, it'll take a lot longer for little benefit in my opinion.
http://ready4dis.8m.com/cgi-bin/i/PhatO ... 271105.JPG
32-bit, preemptive multitasking, virtual memory manager, keyboard, mouse, hdd, fdd, file system (fat), supported VESA (VBE). It wasn't to bad to write, came out to like 12kb total. With the font set and graphics it was a whopping 24kb. The GUI was written in C, the OS written in assembly. While it was a great learning experience, which is the reason I did it in the first place, I re-wrote it in C as I originally planned. I don't have any benchmarks, but I doubt the asm version is any faster in reality, and the fact that it's much easier (for me) to implement more advanced algorithms in C, the C version probably ended up faster in general due to a better design, and it's much easier to extend or use on other hardware. Of course, the C version ended up being much larger, but it also ended up with many more features (virtual file system, vs individual file systems, a better task scheduler, a command line as well as GUI, SMP, and 64-bit is working, but not done...). Could I write it all in asm, yes. Do I want to? No, it'll take a lot longer for little benefit in my opinion.
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Writing Os entirely in assembly
Normally an "update" system is designed such that the device retains the latest version.Kevin wrote:Are you sure? I don't think microcode updates are persistent, so shouldn't a simple power cycle fix things?onlyonemac wrote:I assume you would have acquired an adequate stockpile of CPUs, as it is rather easy to brick them by damaging the microcode.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Writing Os entirely in assembly
Actually I've just researched it some more and the updates are not persistant.
However it is certainly possible to update the microcode on an Intel CPU.
However it is certainly possible to update the microcode on an Intel CPU.
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
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing