Description

16.1 Description

Assembly language is a low-level, pseudo-English representation of the mi- crocontroller’s machine language. Each assembly language instruction has a one-to-one relation to one of the microcontroller machine-level instructions.

High-level languages, such as C, Basic, Visual Basic, etc. are one or more steps above assembly language, in that no significant knowledge of the under- lying architecture is necessary. It is possible (and common) for a developer to program a Visual Basic application in Windows without knowing much of any- thing about the Windows API, much less the underlying architecture of the Intel Pentium. Furthermore, a developer who has written code in C for Unix will not have significant problems adapting to writing code in C for Windows, or a mi- crocontroller such as an 8052; although there are some variations, the C com- piler itself takes care of most of the processor-specific issues.

Assembly language, on the other hand, is very processor specific. While a prior knowledge of assembly language with any given processor will be helpful when attempting to begin coding in the assembly language of another proces- sor, the two assembly languages may be extremely different. Different archi- tectures have different instruction sets, different forms of addressing. In fact, only general concepts may work from one processor to another.

The low-level nature of assembly language programming requires an under- standing of the underlying architecture of the processor for which one is devel- oping. This is why we explained the 8052 architecture fully before attempting to introduce the reader to assembly language programming in this document. Many aspects of assembly language may be completely confusing without a prior knowledge of the architecture.

This section of the document will introduce the reader to 8052 assembly lan- guage, concepts, and programming style.

16.2 Syntax

Each line of an assembly language program consists of the following syntax, each field of which is optional. However, when used, the elements of the line must appear in the following order:

1)Label—a user-assigned symbol that defines the address of this instruc- tion in memory. The label, if present, must be terminated with a colon.

2)Instruction—an assembly language instruction that, when assembled, will perform some specific function when executed by the microcontroller. The instruction is a psuedo-English mnemonic which relates directly to one machine language instruction.

3)Comment—the developer may include a comment on each line for inline documentation. These comments are ignored by the assembler but may make it easier to subsequently understand the code. A comment, if used, must be preceded with a semicolon.

16-2

Page 196
Image 196
Texas Instruments MSC1210 manual Description, Syntax