Minimal game in x86 assembly

Posted by (twitter: @MegaBrutal)
June 12th, 2013 7:32 pm

I took part in Ludum Dare #26 with a minimal DOS game written in x86 assembly. Though I couldn’t finish the game within 48 hours, I got some really nice feedback, also I saw some more potential in the game, which eventually inspired me to finish it after the compo. :)

The game is now (somewhat) playable. It has a HUD which shows your health, how many treasures you collected, and how many monsters you killed. Also, the field is randomly generated, and if you leave the screen, you get a new field (as if you left the previous one). Also, whenever you kill a monster (or you get killed by one), a random name is selected from a list of races – some of these races are shout-outs to various indie games I love – I suggest all the referenced games for everyone to check out. 😉

Some added awesomeness to this game (which I’m really proud of) is that it’s OS-independent: though it runs natively under DOS, it doesn’t actually require DOS to run. To prove this, you can actually write the binary image into the boot sector of a floppy (and possibly other bootable storage media) and then you can directly boot your PC with it. The binary is exactly 3 sectors long, and it contains a boot code which loads the rest of the game if it’s booted by BIOS. Since the game only depends on ROM-BIOS calls those are available in all IBM-compatible PCs since the 80s, the game will run without a traditional operating system – in other words, technically the game will function as your operating system. 😉 (Though I can’t prove it, theoretically this code should run even on the earliest IBM PC model, as well as on today’s PCs. Though I’m not entirely sure that all BIOS functions I used were available since the very beginning.)

Originally I intended to include a readme.txt file for the program, but I found the source code itself is quite self-documenting. So just read the source code and you will find all information you need. (I advocate the “code is design” philosophy anyway. :P)

We must admit, this game is rather a computer science experiment than an actual game. It’s not very fun, I must admit. 😀

You may get the updated game here:

ASM source
ZIP package (contains the source code and the compiled .COM file)

Basically, I had two motives to make this game. One is nostalgia. I remember having fun times reading one of Peter Norton‘s books on assembly programming when I was 13 or 14 (that was like 10 years ago) while others were learning how to get girlfriends. Then during high school’s carefree times I started to work on a hobby operating system I called ShitOS, which would have been entirely implemented in assembly – I was very far from finishing it when I gave it up ’cause I had to realize I don’t have enough free time to work on it. The other reason I made this game is that I think assembly is totally awesome! First, it even looks awesome, I’d totally decorate my walls with it! Second, it does great to the programmer’s soul. To master assembly, you need to understand how the computer works on a deep level, which is a de facto requirement for all good programmers.

Anyway, possible that I’ll develop this game further whenever I get this assembly-fever again. 😉

3 Responses to “Minimal game in x86 assembly”

  1. hilaia says:

    Great job, I had never thought to ASM as an option to little cross-platform games :p .
    Could you tell me how you compile it to a .com on Ubuntu?

    • hilaia says:

      Oh really, you told about it in the .asm. Thank you alot, I’m blind.
      And great job! I’ll try to get myself inspirated if ever I have the time 😉 .

  2. hdon says:

    My mobo has UEFI how do I boot this game?

    I’m glad I saw this post :) Played in dosbox. Thanks!

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]