Texas Instruments MSC1210 User Manual
Page 197
Syntax
16-3
8052 Assembly Language
In summary, a typical 8052 assembly language line might appear as:
MYLABEL: MOV A,#25h ;This is just a sample comment
In this line, the label is MYLABEL. This means that if subsequent instructions
in the program need to make reference to this instruction, they may do so by
referring to MYLABEL, rather than the memory address of the instruction.
The 8052 assembly language instruction in this line is MOV A,#25h. This is the
actual instruction that the assembler will analyze and assemble into the two
bytes 74
H
25
H
. The first number, 74
H
, is the 8052 machine language instruc-
tion (opcode) “MOV A,#dataValue”, which means “move the value dataValue
into the accumulator.” In this case, the value of dataValue will be the value of
the byte that immediately follows the opcode. We want to load the accumulator
with the value 25
H
and the byte following the opcode is 25
H
. As you can see,
there is a one-to-one relationship between the assembly language instruction
and the machine language code that is generated by the assembler.
Finally, the instruction above includes the optional comment “;This is just a
sample comment”. The comment must always start with a semicolon. The
semicolon tells the assembler that the rest of the line is a comment that should
be ignored by the assembler.
All fields are optional and the following are also alternatives to the above syntax:
Label only:
LABEL:
Label and instruction:
LABEL: MOV A,#25h
Instruction and comment:
MOV A,#25h ;This is just a comment
Label and comment:
LABEL: ;This is just a comment
Comment only:
;This is just a sample comment
All of the above permutations are completely valid. It is up to you as to which
components of the assembly language syntax are used. However, when used,
they must follow the above syntax and be in the correct order.
Note:
It does not matter what column each field begins in. That is, a label can start
at the beginning of the line or after any number of blank spaces. Likewise,
an instruction may start in any column of the line, as long as it follows any
label that is also on that line.