I have been using z88dk with my simple z80 homebrew. I have a small monitor program written in assembly, and have a set of test/example programs in assembly and C.
I have gradually been evolving some conventions with my code - to make it easier to understand and maintain, and also so that the monitor is easier to interface with. These are generally "what makes sense to me", but I'd like to know if there are general conventions that would be good to follow, or whether my conventions could be confusing or setting me up to fail.
In assembly I have "callable" labels in lowercase, jump addresses and data labels in uppercase. I have started indicating that a label is private by prepending with an underscore:
Code: Select all
START:
ld hl,WELCOME_MSG
call puts
...
_myprivatefunction:
ld a, SOME_VALUE
...
puts:
...
When I come to write example assembly programs that call into the monitor, I have now started to include the map file generated z88dk-z80asm in my examples, which works great, although I'm likely going to remove all the "private" labels from the map file.
When it comes to building C programs that call into the monitor, this too is working fine by including the map file. I have an asm file that I include on the zcc build - something like:
Code: Select all
include "monitor.map"
PUBLIC fgetc_cons
PUBLIC _fgetc_cons
fgetc_cons:
_fgetc_cons:
call getchar ; monitor function - waits for input
ld l,a
ld h,0
ret
PUBLIC _readchar
_readchar:
call readchar ; monitor function
ld l,a
ld h,0
ret
The above code compiles and runs fine, but is it OK to omit the label variant without the underscore? Why in the z88dk example are both variants included?
Obviously I could rename the label in the monitor program, or rename it only in the map file. But maybe it would be better to prepend all the monitor labels for better separation? I'd like to understand what the z88dk / general best practice considerations are!
Thanks in advance!