Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the advantage of writing an OS entirely in assembly? [closed]

MenuetOS is an example of an OS written entirely in Assembly. Is there any advantage to writing it in Assembly instead of a low-level programming language such as C?

like image 495
Lawand Avatar asked Aug 19 '09 21:08

Lawand


2 Answers

Interfacing with an OS tends to be easiest in the language it was written in -- C in UNIX and Win32, C++ in BeOS, etc. MenuetOS was designed specifically to make developing assembly applications easy, so the best choice was to write the OS itself in assembly.

For OSes which aren't intended to be general-purpose, such as embedded systems and microcontrollers, the overhead introduced by mechanical translation (ie compilation) of C into assembly can be unacceptable. Compilers aren't as smart as humans, especially when it comes to the sorts of fiddly little optimizations required on embedded platforms, and writing directly in assembly guarantees there won't be a compiler mucking up carefully-designed algorithms.

like image 70
John Millikin Avatar answered Nov 24 '22 18:11

John Millikin


Presumably you can write a compact and fast OS. Though you may not be able to write it quickly, and you lose any hope of trivial portability.

like image 26
dmckee --- ex-moderator kitten Avatar answered Nov 24 '22 16:11

dmckee --- ex-moderator kitten