Nascom Newsletter |
Volume 2 · Number 5 · November 1982 |
Page 2 of 37 |
---|
This series of articles sets out to show you how to write a Z80 disassembler for your Nascom. I wrote mine using a NII with Nas-Sys 1 but I do not see different monitors will make any difference, so long as you know your machine. These articles make extensive use of the algorithm in Tony Baker’s excellent book “Mastering Machine Code On Your ZX81”. Indeed, it was from this book that I wrote my disassembler. The final program, which also includes the option of ‘Single Stepping’ through a disassembled program, should occupy less than 1800 (decimal) bytes.
It is essential to fully understand the monitor of the Nascom before launching yourself into a task of such mammoth dimensions. My disassembler, named ‘The Beast’ (and also many unrepeatable words), took 6 weeks to write and involved most of my time during that period. I was at home all day!! I had just finished my A’Levels and was looking for some light relief. Do not despair if you have to scrap your disassembler and start again. Mine is version 3, and each version is always a great improvement on its predecessor!
This first article will set up the program and start the very beginnings of your disassembler.
The program uses certain variables which must be stored somewhere. Some can be saved in the Z80s very useful alternate set of registers (ie BC’, HL’ etc). The rest will have to be stored in RAM. One important point to note is the corruption of variables by subroutines, especially those in the alternate registers. So take suitable precautions with your subroutines. None of the Nas-Sys 1 routines I used interfered with the alternate set. But do be careful.
One particular variable that requires some fore thought is that of STRDIS. That is the variable that holds the string of characters that make up the disassembled instruction. This will be printed using Nas-Sys, and so must be stored as a string of ASCII codes.
A method of marking the end of STRDIS must be used or some pointer system. The marker or pointer will have to be easily changed by any part of the disassembler needing to change STRDIS. I used £FF (£ will always represent base 16 or hex) as a marker. The reason for the marker is that the length of STRDIS is unknown. It can vary from, for example, CP B to LD HL, (£1000). So be aware of STRDIS’s needs, and make it the last variable in a table, so that it can grab all the RAM at needs!!!
Page 2 of 37 |
---|