Why were old games programmed in assembly when higher level languages existed?

Mudassir Ali
Feb 04, 2020 03:44 PM 0 Answers
Member Since Dec 2019
Subscribed Subscribe Not subscribe
Mudassir Ali
- Feb 04, 2020 03:45 PM

Yesterday, a programmer friend from college called me up. He was working on a vehicle controller for a watercraft. They had to calibrate this controller with some test data. They had only 8KB of memory. And all the “calibration data” was taking up a whopping 2 KB of memory. Their “young” programmer was worried they were going to run out of memory for the actual control program. And he wasn’t wrong.

Now, I’m considered an “old” guy. Old enough to remember how to actually cram a lot of code into a very small space. How to write that program instruction by instruction. So, I took their 2KB data and—15 minutes later—wrote a quick routine that just calculated the tabular data on the fly (yes, good reasons and bad reasons to do this; I’m aware). And it all fit into <200 bytes. So, that’s about 90% space savings. Which is pretty good.

Again, only 8 KB to work with. Most programmers today have no experience with programming with so little memory to work with. So it’s hard to imagine how little space that is. Need a visual? Here:

Here’s a classic image. It’s just over 1 KB in size. So, imagine all the memory space you have—program and data—is slightly smaller, byte-wise, than 8 of these images.

Doesn’t seem like very much, does it? Because it’s not much space at all.

Now, here is the Nintendo Entertainment System. One of the most successful video game platforms—probably the one that really solidified video games as a viable market in the United States:

It has 2 KB of “working” memory.

Meaning, you need to fit your data and any extra program code into less than this space:

They used rather ingenious bitmapping, sprite tables, and color pallete rotations to simulate a lot of visual display functionality. Here’s a dump from a table from Nintendo’s Super Mario Brothers.

You can see that a lot of the graphic elements are really crammed together. And then, the functionality was tightly coded to reference elements in that table to simulate motion. Remember when an old NES game would crash and you’d get random “parts” of the game smattered everywhere? Yep. Something in the tightly packed space went wrong…

Could you have done all this in high-level languages? Sure. Theoretically. But theory isn’t practice. At this stage of game development, bytes mattered. In short, there is no space to waste on these old machines. Every instruction was hand-coded and tweaked so it could fit on the machine.

Update: This got way more upvotes than I expected. Not sure why! Thanks for all your positive comments.

For everyone who’s been asking me more about how the NES works, here’s a great little teaser video. Which really captures the “neatness” of the NES.

If you’re a programmer or aspiring programmer, I strongly urge you to learn more about about your craft. Maybe this video will suggest a few “neat” things to you—especially on design (“Wow, the controller fits all its input in 1 byte. How convenient!”).

Reply on This
Replying as Submit
0 Subscribers
Submit Answer
Please login to submit answer.
0 Answers