Chapter 3 Introduction to Operation

3.4Assembling and Linking Multiple Sections

In section 3.3, "Basic Operation of the Assembler and Linker", source files each comprising one section were assigned to the same section as a basic example. However, normally a program will be divided into multiple sections to clearly divide programs by function and type.

The start addresses of a program in section format are set for each section during linking. Therefore, when a program divided into multiple files is developed, work can proceed without the programmer staying aware of the code size of each file. The programmer an also freely change the order in which files are linked.

The following explanation illustrates a simple example dividing two source files into sections for each routine, allocated to two sections.

Create source files

Using an editor, create the two programs shown below (program3.asm and program4.asm). The contents of program3.asm are as follows.

 

global

main

_CODE_00

global

data_set, time_filler

section

CODE, PUBLIC, 1

main

mov

0, A0

 

 

mov

0xff, D0

 

mov

0x80, D1

 

jsr

data_set

 

jsr

time_filler

 

bra

main

_DATA

section

DATA, PUBLIC, 4

data1

ds

4

 

end

 

30 Assembling and Linking Multiple Sections

Page 42
Image 42
Panasonic MN1030 user manual Assembling and Linking Multiple Sections, Create source files