In Windows, when programming in Assembly -- say, inline assembly in a .cpp file within Visual Studio -- the development environment protects me from my own stupid mistakes. If I clobber the ESP register when a subroutine exits, it lets me know that specific thing happened, but it otherwise remains sunshine. When I'm not paying attention and have my code write to an 开发者_C百科invalid memory location, the only thing that crashes is my own program, which I can immediately go back to editing just seconds later. In DOS, these errors always require a reboot.
I understand a lot of this is due to Windows having a different memory model than DOS's (virtual/protected mode versus real-mode), which is why crash-prone Windows programs, for the most part, rarely do damage beyond their own territory of execution.
But I was still wondering if there has ever existed, past or present, a DOS utility that acts as a kind of safety net for executables-in-progress that reduces the chances of the entire DOS environment (read: the computer itself, or at least the emulator running DOS) from freezing up over a low-level developer error?
You could write your program with a 32-bit DOS Extender in mind, such as DOS/4G, DOS/32, etc - which starts a Protected Mode wrapper around DOS. That would at least catch invalid instructions and most memory errors, print out an exception handler report and dump you back to the DOS shell.
You can still use many DOS/BIOS interrupt functions, but you'd effectively be writing a 32-bit program rather than a 16-bit one.
精彩评论