Hc12 Assembler

Páginas: 42 (10406 palabras) Publicado: 14 de junio de 2012
2
68HC12 Assembly
Programming
2.1 Objectives
After completing this chapter you should be able to:

• Use assembler directives to allocate memory
blocks, define constants, and create a message
to be output

• Write assembly programs to perform simple
arithmetic operations

• Write program loops to perform repetitive
operations

• Use program loops to create time delays
• UseBoolean and bit manipulation instructions
to perform bit field manipulations

30

Chapter 2

s

68HC12 Assembly Programming

2.2 Assembly Language Program Structure
An assembly language program consists of a sequence of statements that tells the computer
to perform the desired operations. From a global point of view, a 68HC12 assembly program
consists of three sections. In some casesthese sections can be mixed to provide better algorithm
design. The three sections are:



Assembler directives. Assembler directives instruct the assembler how to process
subsequent assembly language instructions. Directives also provide a way to
define program constants and reserve space for dynamic variables. Some directives
may also set a location counter.



Assembly languageinstructions. These instructions are 68HC12 instructions.
Some instructions are defined with labels.



Comments. There are two types of comments in an assembly program. The first
type is used to explain the function of a single instruction or directive. The second
type explains the function of a group of instructions or directives or a whole routine. Adding comments makes a program morereadable.

Each line of a 68HC12 assembly program, excluding certain special constructs, is comprised of four distinct fields. Some of the fields may be empty. The order of these fields is:
1. Label
2. Operation
3. Operand
4. Comment

2.2.1

The Label Field

Labels are symbols defined by the user to identify memory locations in the programs and
data areas of the assembly module. For mostinstructions and assembler directives, the label is
optional. The rules for forming a label are as follows:



A label must start at column one and begin with a letter (A-Z, a-z), and the letter
can be followed by letters, digits, or special symbols. Some assemblers permit special symbols to be used. For example, the assembler from IAR Inc. allows a symbol
to start with a question mark (?),at character (@), and underscore (_), in addition to
letters. Digits and the dollar ($) character can also be used after the first character
in the IAR assembler.



Most assemblers restrict the number of characters in a label name. The as12
assembler reference manual does not mention the limit. The IAR assembler allows
a user-defined symbol to have up to 255 characters.



The as12assembler allows a label to be terminated by “:”.

Example 2.1

w
Valid and Invalid labels.
The following instructions contain valid labels:
begin ldaa
#10
; label begins in column 1

2.2

s

Assembly Language Program Structure

print:
jmp

jsr
begin

hexout

31

; label is terminated by a colon
; instruction references the label begin

The following instructionscontain invalid labels:
here is adda
#5
; a space is included in the label
loop
deca
; labels begins at column 2

v
2.2.2

The Operation Field

This field contains the mnemonic names for machine instructions and assembler directives.
If a label is present, the opcode or directive must be separated from the label field by at least one
space. If there is no label, the operation fieldmust be at least one space from the left margin.

Example 2.2

w
Examples of operation fields
adda
#$02
; adda is the instruction mnemonic
true
equ
1
; equate directive equ occupies the operation field

v
2.2.3

The Operand Field

If an operand field is present, it follows the operation field and is separated from the operation field by at least one space. The operand field may...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • HC12
  • Assembler
  • Assembler
  • Assembler
  • assembler
  • Pwm Assembler
  • Intrupciones Assembler
  • Calculadora Assembler

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS