I’m So Awful at JuMPing!

After showing how to display an image via the boot sector and some fancy disk loading, I decided to try my luck at actually starting a program from disk.  Reading from the disk is actually quite easy thanks to BIOS interrupts as long as one knows the location on the disk (in terms of tracks/sectors) where the data to load exists.  A logical extension of this idea is to load up a program from disk and execute the code.

Obviously I’m not attempting to implement an operating system of any sort, so the goal is actually to just execute some simple code that is easy to locate on a floppy disk.  To execute arbitrary code, however, one needs to understand what exactly they are attempting to execute.  In the MS-DOS world, we have two general types of executables, COMs and EXEs.  COM files are always rather small, while EXE files can span a wide variety of sizes.  After some mild research on Wikipedia, it turns out, as one might expect, that the COM format is rather simple. When a COM file is executed, MS-DOS loads the entire file into memory offset 0×0100 and allows the program to begin execution.  Easy!  The EXE format, also known as DOS MZ format apparently, is somewhat more complicated and way beyond the scope of this RetroChallenge.

Based on the code used to write data to a screen, I authored a slightly modified version that would load the contents of a COM file into memory at the correct offset.  Once loaded, the assembly would simply jump (JMP) to the address, 0×0100, and continue execution, thereby running the COM program.  While this sounds rather simple, there are some major caveats.

First of all, the COM program I was attempting to load was much bigger than the 4000 byte screen I was loading previously.  This larger size means that the data is spanning multiple tracks, which might or might not be a problem.  I chose to not actually think about this issue.

Second, the chosen COM file must not rely on any MS-DOS services to work properly.  While this seems like a simple, reasonable request, one must consider any and all calls to MS-DOS interrupts, which can be used for simple things like text output.   To be safe, the COM file I chose was previously a PC Booter, the game Zaxxon.  I made sure first that this game ran like a dream on the Tandy 1000 before proceeding with my experiments.  Because the game is purely graphics and was previously packaged as a PC Booter (it was converted to a COM file by pirates at some point), there should have been no reliance on DOS itself.

I’ve messed around all evening with trying to get the game to start directly via the boot sector to no avail.  The best result I seemed to arrive at was some garbage appearing, in text, in the upper left corner of my screen.  Since I can’t quite resolve the issue, I’ll try something different for my last little RetroChallenge project.

Discussion Area - Leave a Comment

You must be logged in to post a comment.