Z80 Assembler programming

OK, so you want to start with Z80 assembler programming, listed here are some steps I have taken to get an environment set up in which I can start programming.

I am using a Windows 7 environment, so your setup may be different.

To set up the same environment I am using you can follow these instructions:
Firstly you want to get yourself a copy of Programmer's Notepad which is available free from here.
Next you need to get the assembler, I use TNIASM which I got from here.
I also use a freeware hex editor called XVI32 which can be found here.

Once you have it all set up, open Programmer's Notepad. Then go to the Tools menu and select options. you should be presented with this dialog:
this screenshot already shows the Assemble code setting, but you will need to add it.

Now you need to click the Add button and fill out the 2 tabs the same as what I have below

Where command is, press the ... button and select your copy of tniasm.exe

now we have an assembly environment set up, lets test some code to make sure it is working nicely

        org 0x00
reset:  jp start

        forg 0x0066 ; set NMI vector
nmi: ld a, 0x4d
ld (0x4013), a
jp 0x4000


forg 0x0100 ; put this out of the way
start: call loop
ld a, 0x4d
ld (0x4010), a
ld a, 0x4d
ld (0x4011), a
ld a, 0x4d
ld (0x4012), a
        jp 0x4000

loop: jp loop

Save the file (mine is saved as test1.asm) and go to the tools menu and select Assemble. a new pane should open up in Programmer's notepad and should have something similar to this:

> "C:\Users\Peter\Dropbox\Z80 stuff\tniasm045\tniasm.exe" test1.asm test1.bin
Preprocessing...
Pass 1...
Pass 2...
Generating Output...
Finished in 0.03 seconds.

> Process Exit Code: 0
> Time Taken: 00:01

If your output doesn't produce a similar result, check your settings in the Assemble command.

If your like to view the binary output to make sure everything is where is should be, then you may want to add a command to open up the binary file you just made in a hex editor, I use XVI32 and the settings for the new command is as follows (use the same steps above to add it):

Having added both commands and assembled the example I gave, click the Open BIN in XVI32 command will open a window like this:

This should start you off nicely. I will add more info here as time goes on.

Bye for now.


Comments