Chapter 2 Program Development Flow

Conditional assembly

If a program for product A is to be created by partially modifying a program for product B, both can be combined into a single program by using conditional assembler control instructions.

Conditional assembly is done by defining a single symbol at the start of the program using a define control directive.

Here is an example.

#define

TYPE

A

Using TYPE and conditional assembler control directives to process different parts of the program, the programmer writes code in the format below.

.

.

.TYPE Program of product A

#else

Program of product B

#endif

.

.

.

TYPE has been defined with define, so in this case the program for product A will be assembled. If the statement

#define TYPE A

is omitted, the program for product B will be assembled.

By using conditional assembler control directives in this manner, different versions of programs can be managed in a single source file.

[Reference: Chapter 10, "Writing Assembler Control Statements", for details]

Macros

Macros are an important function of the assembler. A macro assigns a name to a process, thereby simplifying the coding of that process. By assigning an appropriate macro name to a block of multiple machine language instructions, the programmer can create custom instructions.

Debugging

When performing final program debugging, the programmer must verify whether the intended operations are being performed or not. A source code debugger is provided for this. The programmer uses the debugger to download generated and linked object code and verify operation.

The g option of the assembler and linker generates information that allows the debugger to work with symbols. This allows symbols to be used for specifying debugger start addresses, breakpoint settings, memory references and changes, etc.

Programming with Assembler 19

Page 31
Image 31
Panasonic MN1030 user manual Conditional assembly, Macros, Debugging