10/16/2006


A student writes:

Hey Dr. Patt, 

Hey, Mr. Student.

Is there a way to add comments into our program so that it's
easier to understand what I'm doing when I come back to my 
program the next day?

<<name withheld to protect the student who does not want to 
start over every day>>

Good question.  One of the best things you can do in writing a program is to
add comments to some lines of code, so it will jar your memory as to what you
have done when you come back to it tomorrow.  After you graduate, you will
probably find that you have to go back and modify a program you wrote two
years ago because the problem for which you wrote the program originally 
has changed.  Without comments, you won't have a chance.  So, good question.

And the answer is: Yes.  Simply put a semicolon after the instruction and 
anything you write after that is ignored by the computer.  For example, in
the program we wrote in class:

0001 010 010 1 11111 ; R2 keeps track of how many values still to go.

By the way, let me ask you a question:  What is BAD about the following
comment:

0001 010 010 1 11111 ; This instruction decrements R2.

On Wednesday, we will leave machine language and start programming in
LC-3 Assembly Language.  ...and we will talk about comments from the gitgo.

Yale Patt