7 ms·
I've wanted to re-implement DOS in pure assembler for years to have that lean and mean that uses less memory than MS-DOS but never had the time.
by mrlonglong 5y ago
I've wanted to re-implement DOS in pure assembler for years to have that lean and mean that uses less memory than MS-DOS but never had the time.
- ok123456 5y agoThe sources for MS-DOS have been floating around the net basically forever. The original first few releases are even on Microsoft's github. It largely is already in ASM. Some of the user programs are written in C. To me, it would be far more interesting to see what modern compilers and development tooling could do towards producing DOS programs and operating system extensions. The tooling from back in the day was very baroque. You had to rely on different mutually incomparable dos extenders to get around all the limitations. (Just try to find the documentation to Phar Lap 386 in 2022.)
- tored 5y agoWhat would writing DOS programs and extenders with modern tooling accomplish? Trying to understand the goal.
- ok123456 5y agoMaking easy to understand and maintain programs in C++, with compilers that can that can do aggressive optimizations and inlining that compilers of the day could not do. The STL didn't exist until the late 90s, and before C++98 it was a wild-west.
- krkixohjk 5y agoBut what is the goal in having maintainable ms-dos software? The OS is still ancient and lacks most every possible security measure. Every program can r/w any memory and so on…
- ok123456 5y agoThe fact that it gets out of your way is a feature. Why does security matter on a single user, non-multitasked environment with no networking? The netsec industrial complex has really set back computing.
- wyldfire 5y agoMSDOS did have MMU support since 80386, IIRC. So I think GPs claim might be inaccurate. But it wasn't a security feature, it was a productivity feature. It protected your programs from defects in other programs and vice versa. This helps programmers find defects during design and helps users for defects that escape testing.
- spc476 5y ago[citation required] for the MMU support of MS-DOS.
- ok123456 5y agohttps://en.wikipedia.org/wiki/Control_register https://en.wikipedia.org/wiki/Control_register
- spc476 5y agoJust replying with a web page showing the 80386 has having control registers doesn't imply that MS-DOS used them in any meaningful way.
- ok123456 5y agoThe MMU is inside the processor. Any operating system running on an 80386 or higher has set registers/tables and gets hardware provided memory management.
- 5y ago
- deckard1 5y ago> with compilers that can that can do aggressive optimizations we're still talking about real-mode DOS here. Most of those optimizations aren't going to work. Regardless, you can target DOS just fine today. You'll need some code to bootstrap your program into protected/long mode and then your app has full freedom. You'll need to figure out the correct switches to pass to gcc to get it output a freestanding binary, and possibly a special linker script, etc. Freedom but, let's be honest, no real utility today. You can't access the network because you'll need to write the entire network stack from scratch. You'll need to write a driver for your network hardware. Can't touch video without writing a driver for your Nvidia hardware. Or sound card. I suspect what most people want from a "modern" DOS would be something like this: a very thin API layer that contains OpenGL (or Vulkan), audio, and networking capability. As well as drivers for common USB devices and something that can read/write FAT/exFAT. But once you add all of that you realize it's nowhere near as lightweight as old DOS was and your app now has a thousand more responsibilities that something like the Linux kernel is currently handling for you.
- lmm 5y ago> I suspect what most people want from a "modern" DOS would be something like this: a very thin API layer that contains OpenGL (or Vulkan), audio, and networking capability. As well as drivers for common USB devices and something that can read/write FAT/exFAT. But once you add all of that you realize it's nowhere near as lightweight as old DOS was and your app now has a thousand more responsibilities that something like the Linux kernel is currently handling for you. I think people may be looking for something like a unikernel framework. Something like Linux is a lot of overhead if all you want to do is run a single program on a machine (virtual or physical).
- hulitu 5y agoTaken into account how the modern compilers evolved, i don't have big hopes. They seem to become more bloated with every release.
- ok123456 5y agoconstexpr code and move semantics didn't exist until relatively recently. These are steps towards less bloat and more aggressive optimization. They also can elide gratuitous copy construction. There are a lot of these little optimizations that are found in modern compilers that you could only dream about in 1991.
- oso2k 5y agogcc-ia16 and OpenWatcom are both modern compilers that generate as good a set of code as any compiler ever did for Pentium and older processors. But using a higher level language like C means there’s more than one compiler that can compile your DOS. That’s a reason to be hopeful if you’re a DOS developer.
- boznz 5y agoThe compilers have probably got better but the C language has definitely bloated since the 80s
- mrlonglong 5y agoPersonally for me it would be an interesting experience to see what and why they chose to do things they did with MS-DOS. One thing to try is to see if it's possible to write a 64 bit DOS extender.
- oso2k 5y agoThere’s a couple attempts at running 64-bit in DOS. It usually has no benefits for old code and very little new 64-bit is being written and there are no libraries for common compilers. https://github.com/Baron-von-Riedesel/Dos64-stub https://github.com/Baron-von-Riedesel/Dos64-stub https://www.bttr-software.de/forum/board_entry.php?id=15853 https://www.bttr-software.de/forum/board_entry.php?id=15853
- mrlonglong 5y agoNice one, thanks.
- userbinator 5y agoI think the parent may be thinking more of "demoscening" the DOS kernel and basically optimising it to its limits. Yes, the original was written in Asm, but it's definitely not that highly optimised.
- 13of40 5y agoIt was written in assembly code: https://github.com/microsoft/MS-DOS/tree/master/v2.0/source https://github.com/microsoft/MS-DOS/tree/master/v2.0/source This is a very old version, but I've seen bits and pieces of the last one they shipped and things like command.com and the "kernel" were nearly the same as this, except for maybe some memory management changes. What part did you want to reimplement?
- bitigchi 5y agoWhy not contribute to FreeDOS?
- Koshkin 5y ago> lean and mean