Chapter 3 Introduction to Operation
Basic Operation of Assembler and Linker 25
3.3 Basic Operation of Assembler and Linker
The Cross-Assembler uses a section address format, in which the start address for each section as
defined with the section directive corresponds to its start address when linked. This allows the
programmer to freely change the order of linking files.
The following explanation illustrates a simple example of only one section. In this example you will
assemble and link two source files, program1.asm and program2.asm.
These two files have related external references and external definitions, where the subroutine of
program2.asm is called from program1.asm. Therefore the final list files cannot be created just by
assembling program1.asm. In this example, you will generate with the linker a map file and generate
the final list files.

Create source files

First, create the source files. Using an editor, create the two programs shown below (program1.asm and
program2.asm).
The contents of program1.asm are as follows.
program1.asm consists of a section called _CODE (attribute CODE, link type PUBLIC) and a section
called _DATA (attribute DATA, link type PUBLIC).
global data_set
__CODE section CODE, PUBLIC, 1
main mov 0, A0
mov 0xff, D0
mov 0x80, D1
jsr data_set
bra main
_DATA section DATA, PUBLIC, 4
data1 ds 4
end