In all forms of programming, it is essential to add comments. These are bits of text that the assembler completely ignores - we add them in to help humans (including ourselves) to understand what the code is supposed to do (on a high level), and why it’s doing what it’s doing (on a low level).
There is one super-hugely-amazingly important reason to add comments to your code: you will forget what it’s doing and why it’s doing it in the way it does, and waste loads of time trying to figure it out. Save yourself the hassle by writing loads of helpful comments.
There are two types of comment: line and block.
In WLA DX, everything that comes after a semicolon “
;” is ignored until the end of the line.
Comment on what you’re doing:
What something is:
You can also comment out code instead of deleting it:
In WLA DX, everything that comes after “
/*” is ignored until “
*/” is found, across multiple lines.
This is useful for commenting out large blocks:
-: ld a,(hl)
Or for making large blocks of explanatory text:
In loving memory of Acorn Computers Ltd.
Mike G proudly presents the:
BBC Micro Character Set!
This source was created automatically
from character data stored in the BBC
Microcomputer operating system ROM.
The BBC set is a nice, clear font which
(unlike the classic Namco/Sega font)
includes lower-case letters as well as
Being a British micro, there's even a
Pound Sterling currency symbol, which
should come in handy when I begin to
write financial apps on the SMS. (Just
Hopefully by using binary representation
it will be obvious how the character
data is stored.
Although you can make these large blocks out of line comments too.