Re:KolibriOS – operating system written entirely in assembly...
by projektfu on Wednesday April 15, 2020 @12:28AM
(#22874506)
The biggest benefit is usually that you can forgo calling conventions in your own code because everything is visible to you. Of course the code starts looking like spaghetti.
[ Parent
| on HN ]
Re:KolibriOS – operating system written entirely in assembly...
by ajxs on Wednesday April 15, 2020 @01:02AM
(#22874694)
This is correct. You can forego all aspects of your platform's calling conventions if you so desire. Omitting setting up stack frames is a really simple optimisation that can be done in hand-written assembly. You've already touched on what the stakes of doing such things are.
Re:KolibriOS – operating system written entirely in assembly...
by jfkebwjsbx on Wednesday April 15, 2020 @06:10AM
(#22876130)
Compilers are able to do the same since a few years.
Re:KolibriOS – operating system written entirely in assembly...
by projektfu on Wednesday April 15, 2020 @08:06AM
(#22876749)
Yes, but they rarely take a whole-program approach. Reducing a complicated sequence of function calls to a few goto’s is not an easy task. Probably NP-hard?
Re:KolibriOS – operating system written entirely in assembly...
by BubRoss on Wednesday April 15, 2020 @01:11PM
(#22880278)
Doing it on a whole program basis is also unlikely to give much benefit. Function calls are extremely fast, they only show their overhead in tight loops.
Re:KolibriOS – operating system written entirely in assembly...
by projektfu on Wednesday April 15, 2020 @06:54PM
(#22884120)
Yeah, reviewing the repository there’s a lot of high level language code now, so that probably removes most of the benefit of assembly. You’re still calling into the OS a lot.
Some of the other low level systems (like the Mac) had a trap system that wasn’t so far away in cycle count from user code. But in these days of needing 10,000 cycles to bridge a system call it’s best to do whatever you can to avoid calling the OS.