Z80 Assembly Program - Dotneteer/spectnetide GitHub Wiki
ZX Spectrum would not be interesting without creating Z80 Assembly programs. The IDE provides this functionality with the help of straightforward tools.
In this article, you will learn how easy is to create and run a simple program written in Z80 assembly.
Create a ZX Spectrum Project with Z80 Assembly Code
-
Run the File|New|Project command (Ctrl+Shift+N), select the ZX Spectrum tab and choose the ZX Spectrum Code Discovery project type. Specify a project name (use SimpleZ80Code).
-
Add a new Z80 Assembly file (use the Add New Item command) to the SimpleZ80Code project and name it Symbols.z80Asm. Change its content to this line:
MainEx: .equ #12ac
- Add another Z80 Assembly file (Code.z80Asm) to the project.
- Type this short code into Code.z80asm:
; Code file
#include "Symbols.z80Asm"
.org #8000
ld a,#04
out (#fe),a
jp MainEx
This short code sets the border color to green, and immediately jumps to
the main execution cycle (MainEx
) of the ZX Spectrum ROM, which accepts
BASIC commands.
Run the code
The context menu of .z80Asm
files contains a command, Run Z80 program,
which does exacly what its name suggest.
When you invoke it, it compiles the Z80 assembly code into Z80 binary code. When the compilation is completed, it starts (restarts) the ZX Spectrum virtual machine. After the startup, it loads the binary code and executes it.
When you run the Code.z80Asm file, it works as expected, and sets the border color to green:
Check Compilation Errors
Of course, your Z80 assembly code may contain errors. For example, if you change the content of the Code.z80Asm file to this, you add an error:
; Code file
#include "Symbols.z80Asm"
.org #8000
ld c,#04
out (#fe),c
jp MainEx
When you try to run this code, the IDE shows the Error List tool window with the message that shows the issue: