ZX Spectrum Programming

Latest Tweet:

ZX Spectrum Programming

Below I have created some programs written in z80 assembly language to run on the Sinclair ZX Spectrum, well in an emulated environment.

I have not provided many technical details about how these programs work, however the code has been written as an educational resource therefore the code has been commented comprehensively, in order to explain the inner workings of the program.

Assembling the code

I recommend using the cross platform pasmo assembler, which all of the programs below have been tested with. Pasmo is hard to come by these days but you can install pasmo on many Linux distributions from their standard package managers.

The original homepage for downloads of pasmo is http://www.arrakis.es/~ninsesabe/pasmo/ however the downloads seem to be broken as of the time of writing. Therefore you may be able to find a source download or binary download by searching the internet for the filenames listed on that page.

The command line for assembling the code is:

pasmo --tapbas <Program>.asm <Program>.tap

Where <Program> is your program name.

There are other command line switches that pasmo can use for a list of these, and if you know what your doing, consult the man page or the README file.

Running the code in an emulator

If you are on a Unix system I recommend the excellent FBZX program which seems to be very stable for me (can be downloaded from http://www.rastersoft.com/fbzx.html). I have tried many other emulators however I have encountered problems running/installing the emulator.

In order to run the assembled *.tap file in FBZX you can use the command line:

fbzx <Program>.tap

Where <Program> is your program name.

The configuration options in FBZX are all inbuilt into the emulator itself.

Some helpful options to enable are:

  • F4 -> 3 (Sinclair 128K) - Set the machine to emulate as the Sinclair 128K
  • F4 -> D (Double Scan) - Provide decent graphics
  • F8 - Reference of the spectrum keyboard. NOTE: The arrow keys are not where you think they are!
  • F3 -> 3 (Fast/Normal Speed) - Do this if Fast load disabled is displayed at the bottom of the screen. This enables the tape (Your program) to be loaded very quickly, instead of the original speed of the spectrum (Urgh!).

Once you have launched FBZX with the command line above hit enter to use the tape loader to load your program.

If you are on the Windows platform I recommend ZX Spin which can be found by searching using Google, it seems that the emulator software is rarer than the actual machines. I may provide instructions on how to use ZX Spin at a later date.

2 different file formats?

I provide my assembly programs here in 2 different file formats: Unicode and ASCII.

The Unicode files contain special characters that I use in my comments in order to have pretty boxes around the text. However these are not displayable in some text editors. Therefore I also provide standard ASCII files which you should be able to open in any editor of your choice.

If you do not have a clue what the paragraph above is on about, pick the ASCII file.

Licence

All of the programs below are released under the GNU GPL v3 licence.

Program 1: Blank Screen

This is a very simple program that blanks the screen of the spectrum. Nothing more, nothing less.

BlankScreen.asm (Unicode)

BlankScreen.ascii.asm (ASCII)

Program 2: Move Character

This character moves a character using the H(Left) J(Down) K(Up) L(Right) vim keys to move a character on the screen.

MoveCharacter.asm (Unicode)

MoveCharacter.ascii.asm (ASCII)