2.2 Assembly Language Program Structure

We begin by covering the basics of how it is structured. In HCS12 assembly program, each line — excluding certain special constructs — is made up of four distinct fields.

Figure 2.1 A sample program.

Figure 2.1 A sample program.

The order of these fields are:

  1. Label
  2. Operation
  3. Operand
  4. Comment

For now, don’t worry about what each line of code means, but focus on how it’s structured. Note that some of the fields may be empty or optional.

The Label Field

Labels are used to identify memory locations in the programs and data areas. It is optional. The rules for forming a label are as follows:

The Operation Field

The operation field occurs after the label field and must be preceded by at least one white-space character — i.e. must not start at column one. There are two types of entries: