Programing z80 applications is an exercise in minimalism. Maintaining a tight control on the amount of memory you use and more importantly knowing how much memory is left, is vital. Some assemblers make this process easy, others, less so.
There is a pseudo-symbol
$ supported on most if not all assemblers.
$ evaluates to the current memory location of the instruction being output. You can assign the value of
$ to a symbol at any point.
Here’s a cut down version of Fred’s main file, with a very much truncated list of includes!
The last line assigns the difference between the current code gen location and the start of the application to the symbl
Now, if you assembler supports the output of the symbol file at the end of the process (and it should,) then when you look at the symbol table, you will see the total number of bytes used.
In my case
And showing me that I’m using
41f8 bytes of data or 16888 in decimal money. So with all my game graphics loaded and may be a tenth of the logic implemented I have a hair under half the available memory left. Which puts me in a pretty good position. I have not even started cheating yet and stuffing data into the screen buffer :-)
If like myself you are a user of the Visual Studio ZX Spectrum IDE by Istvan Novak (Git Hub repo) , then this process is made much easier. In visual studio navigate to the menu item
ZX Spectrum IDE > Z80 Assembler output
This will pop open a window within the IDE, that in addition to the symbols list, has a summary tab that shows the total amount of memory used.
As usual SpecNet IDE is proving to be my IDE of choice for spectrum development. Which you can read about here.