Learning Challenge: ZX Spectrum machine code: Days 1-3

For the month of July I've decided to try to do what I initially thought I should do in June: Learn Machine Code on the ZX Spectrum. The ZX Spectrum for those who don't know is a machine that was released primarily in the UK and was the equivalent of the Commodore 64 in the United States. (AKA: it was everywhere). So why learn to program machine code on a machine that is over 30 years old and was never "a thing" over in the United States? One reason is the ZX Spectrum was designed like its predecessors (the ZX80 and ZX81) with development in mind. The version of BASIC that comes with the ZX Spectrum makes it incredibly easy to write machine code and have it executed, even moreso than my beloved Atari machines. Better still: the ZX Spectrum was released early on with a complete disassembly of the internal ROM, and was very well documented. So there's plenty of material available to look at for understanding the internals of the machine. Conversely the Atari 8-Bit machines have custom chips that were kept secret and were only publicly documented later in life (De Re Atari is one example).

So in the past few days I've set up an assembler environment and had modest success with getting programs running. I'm using the excellent Mastering Machine Code on Your ZX Spectrum and am working through chapter 3. What makes this book unique is it doesn't have you using an assembler to enter machine code. Oh no, that's too easy. Instead you insert the code using a <10 line BASIC program and enter the machine code using hex. So you're "poking" the code directly into memory. Unfortunately I'm not able to get the BASIC code she has working completely (or at least I'm not sure what I'm doing wrong) so I'm cheating a bit and using Zeus Assembler to assemble my code.

That's also one of the fun things I've run into with this experiment: using an emulator instead of a native machine. So in order to save the program I wrote in BASIC I needed to figure out how to save it in the FUSE. That and the keyboard for the ZX Spectrum requires special mnemonics for certain functions that can't just be typed (eg: You need to find the STOP key instead of typing S T O P).

All in all I'm having a blast though and learning a bit more about how the ZX Spectrum works and how folks programmed this classic machine. Is it something I can use in my every-day life? Perhaps. All computers some form of machine code. But it's highly impractical to learn it on an older computer and frankly that's the point. This is a computer with very straightforward architecture that begs to be programmed and used. And use it I shall.

I'll be blogging my progress again like I did with the Javascript Learning Challenge. But this time around I think I'm going to have a lot more fun. I hope you stick around.


Comments !

links

social