Hi all
Jut wanted to ask everyone's advice on using assembler for the entire kernel and OS. I'm not using threads and only one core and no GUI (only text) so it's fairly simple (for now) .. I know assembler much better than C and am comfortable writing the code I need in it. Is there an advantage in writing it in C other than readability or debugging?
Bipman
Assembler for all of the kernel
Re: Assembler for all of the kernel
It works.
As long as you are a lone developer and do not leave the project for prolonged periods of time it works.
As soon as you leave it for 6 months and then come back you'll find it easier to rewrite everything from scratch.
It's not portable (obviously).
It's nearly impossible to interest other people in such a project because of this.
Recap: if you're comfortable with asm and don't plan to bring in other devs you're absolutely fine with writing your OS in pure asm.
If you eventually change your mind, it will be relatively simple to rewrite it to C (almost direct translation modulo tricks).
As long as you are a lone developer and do not leave the project for prolonged periods of time it works.
As soon as you leave it for 6 months and then come back you'll find it easier to rewrite everything from scratch.
It's not portable (obviously).
It's nearly impossible to interest other people in such a project because of this.
Recap: if you're comfortable with asm and don't plan to bring in other devs you're absolutely fine with writing your OS in pure asm.
If you eventually change your mind, it will be relatively simple to rewrite it to C (almost direct translation modulo tricks).
Learn to read.
Re: Assembler for all of the kernel
Hi,
Note that debugging well written assembly (that was intended for maintainability rather than performance) can be easier than debugging C; because the source looks the same as a disassembly (which helps when single-stepping to investigate why it crashed), and you know exactly what should be in the CPU's registers and on the stack at any point (so the typical "dump of contents of registers" information you get from a kernel panic/"blue screen of death" is far more useful, especially on real hardware).
Cheers,
Brendan
Performance. For assembly you have to choose between maintainability and performance, and for larger projects you need maintainability more. Also, you can't just tell a compiler (e.g.) "optimise for Haswell CPU instead of Pentium II" - you need to rewrite everything to tune it for a specific CPU.Bipman wrote:Jut wanted to ask everyone's advice on using assembler for the entire kernel and OS. I'm not using threads and only one core and no GUI (only text) so it's fairly simple (for now) .. I know assembler much better than C and am comfortable writing the code I need in it. Is there an advantage in writing it in C other than readability or debugging?
Note that debugging well written assembly (that was intended for maintainability rather than performance) can be easier than debugging C; because the source looks the same as a disassembly (which helps when single-stepping to investigate why it crashed), and you know exactly what should be in the CPU's registers and on the stack at any point (so the typical "dump of contents of registers" information you get from a kernel panic/"blue screen of death" is far more useful, especially on real hardware).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
- TightCoderEx
- Member
- Posts: 90
- Joined: Sun Jan 13, 2013 6:24 pm
- Location: Grande Prairie AB
Re: Assembler for all of the kernel
That statement does have an air of legitimacy about it, but if you take it upon yourself to adequately document, it is not that problematic. You may want to consider too, well written C can come in as tight or maybe more so, than assm. Then again, it is in fact it takes an assembly programmer to make C work like that. At a glance, you can often get an idea of what is going on in a procedure as one line of C can translate into a dozen or so lines of disassembly. The problem is and especially as it applies to me, well written it is directly proportional to knowledge of. What I know about C can be written on a sticky note and to break away from what I consider important, learning an HLL is a distraction.dozniak wrote:As soon as you leave it for 6 months and then come back you'll find it easier to rewrite everything from scratch.
Re: Assembler for all of the kernel
Thanks all. It's more of an embedded type of OS for one task rather than a general one so I think, for now, I'll stick with assembler.
Bipman
Bipman