All assembler statements have the same form. Each statement contains an opcode and operands. Some statements also contain a label and some statements also contain a comment. Some statements with just opcode and operand are:
B LOOP PACK PNO(3),ZDNO MVC MSG(5),=C'ERROR'
Some statements which also contain a label are:
BLANK DC CL133' ' LOOP GET FILE1,RECORD NEXTTEST CLC WEIGHT,LOW
Some statements which also contain a comment are:
PUT FILE2,TITLE WRITE TITLE LA R4,1(R4) POINT TO NEXT LETTER INPUT RECORD DC C' ' RECORD FOR INPUT AND OUTPUT
You may see that the parts of a statement are determined by position. The first part is the (optional) label. The second part is the opcode. The third part is the operand. The fourth part is the (optional) comment. Each of these parts is separated by at least one blank. The label, opcode, and operand parts cannot contain any blanks. It is almost impossible to read an assembler program if the statement parts don't line up, so we use extra blanks between the parts to make the parts of all statements line up, as in the examples above.
A comment statement in an assembler program is created by placing an asterisk (*) in position 1.
There are very strict rules for formatting assembler programs. In C++ we have a lot of flexibility in how we format our code. We use indentation to make the program more readable, but the indentation is optional. We can continue statements on multiple lines, use blanks within statements or leave them out, and leave blank lines in our code. In assembler, we must be very careful about exactly how we format our code. Since blanks are used to separate the parts of a statement, we cannot have any blanks within a part. There are other rules (stated below) which must be followed exactly. Failure to follow the formatting rules will result in errors during assembly or execution.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2002