Chapter 3 Introduction to Operation

3.3Basic 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.

__CODE

global

data_set

section

CODE, PUBLIC, 1

main

mov

0, A0

 

 

mov

0xff, D0

 

mov

0x80, D1

 

jsr

data_set

_DATA

bra

main

section

DATA, PUBLIC, 4

data1

ds

4

 

end

 

program1.asm consists of a section called _CODE (attribute CODE, link type PUBLIC) and a section called _DATA (attribute DATA, link type PUBLIC).

Basic Operation of Assembler and Linker 25

Page 37
Image 37
Panasonic MN1030 user manual Basic Operation of Assembler and Linker, Create source files