When writing code, it is very helpful to use some comments explaining what is going on. A comment is a section of regular text that the assembler ignores when turning the assembly code into the machine code. In assembly comments are usually denoted with a semicolon ";", although GAS uses "#" for single line comments and "/* ... */" for multi-line comments.
Here is an example:
Label1: mov ax, bx ;move contents of bx into ax add ax, bx ;add the contents of bx into ax ...
Everything after the semicolon, on the same line, is ignored. Let's show another example:
Label1: mov ax, bx ;mov cx, ax ...
Here, the assembler never sees the second instruction "mov cx, ax", because it ignores everything after the semicolon. When someone reads the code in the future they will find the comments and hopefully try to figure out what the programmer intended.
mov(ax, bx); //This is a C++ comment. /*mov(cx, ax); everything between the slash-stars is commented out. This is a C comment*/
C++ comments go all the way to the end of the line, but C comments go on for many lines from the "/*" all the way until the "*/". For a better understanding of C and C++ comments in HLA, see Programming:C or the C++ Wikibooks.
Read in another language
This page is available in 1 language