SLAU131Y October 2004 – June 2021
This example uses three source files. The files module1.asm and module2.asm both include the file globals.def.
module1.asm
.global dflag
.global array
.global offset
.bss dflag,1
.bss array,100
.text
MOV &array,R11
MOV &offset,R12
ADD R12,R11
MOV @R11,&dflag
module2.asm
.global dflag
.global array
.global offset
.bss offset,1
.text
MOV &offset,R14
globals.def
.global dflag
.global array
.global offset
The following steps create absolute listings for the files module1.asm and module2.asm:
Step 1: | First,
assemble module1.asm and module2.asm:
This creates two object files called module1.obj and module2.obj. |
Step 2: | Next, link module1.obj and module2.obj using the following linker command file, called bttest.cmd: |
--output_file=bttest.out
--map_file=bttest.map
module1.obj
module2.obj
MEMORY
{
RAM: origin=0x0200, length=0x0800
FLASH: origin=0x1100, length=0xEEE0
}
SECTIONS
{
.bss: >RAM
.text: >FLASH
}
Invoke the linker:
This command creates an executable object file called bttest.out; use this file as input for the absolute lister. |
|
Step 3: | Now, invoke the absolute lister:
This command creates two files called module1.abs and module2.abs: module1.abs: |
.nolist
.text .setsym 000001100h
__text__ .setsym 000001100h
etext .setsym 000001112h
__etext__ .setsym 000001112h
.bss .setsym 000000200h
__bss__ .setsym 000000200h
end .setsym 000000266h
__end__ .setsym 000000266h
array .setsym 000000201h
dflag .setsym 000000200h
offset .setsym 000000265h
.setsect ".text",000001100h
.setsect ".bss",000000200h
.setsect ".debug_line",000000000h
.list
.text
.copy "module1.asm"
module2.abs: |
.nolist
.text .setsym 000001100h
__text__ .setsym 000001100h
etext .setsym 000001112h
__etext__ .setsym 000001112h
.bss .setsym 000000200h
__bss__ .setsym 000000200h
end .setsym 000000266h
__end__ .setsym 000000266h
array .setsym 000000201h
dflag .setsym 000000200h
offset .setsym 000000265h
.setsect ".text",00000110eh
.setsect ".bss",000000265h
.setsect ".debug_line",00000003ah
.setsect ".debug_info",00000014fh
.list
.text
.copy "module2.asm"
These files contain the following
information that the assembler needs for Step 4:
The .setsym and .setsect directives are useful only for creating absolute listings, not normal assembly. |
|
Step 4: | Finally, assemble the .abs files
created by the absolute lister (remember that you
must use the --absolute_listing option when you
invoke the assembler):
This command sequence creates two listing files called module1.lst and module2.lst; no object code is produced. These listing files are similar to normal listing files; however, the addresses shown are absolute addresses. The absolute listing files created are module1.lst (see module1.lst ) and module2.lst (see module2.lst). |
module1.abs PAGE 1
17 001100 .text
18 .copy "module1.asm"
A 1 .global dflag
A 2 .global array
A 3 .global offset
A 4 000200 .bss dflag,1
A 5 000201 .bss array,100
A 6 001100 .text
A 7 001100 421B MOV &array,R11
001102 0201!
A 8 001104 421C MOV &offset,R12
001106 0265!
A 9 001108 5C0B ADD R12,R11
A 10 00110a 4BA2 MOV @R11,&dflag
00110c 0200!
No Assembly Errors, No Assembly Warnings
module2.abs PAGE 1
18 00110e .text
19 .copy "module2.asm"
A 1 .global dflag
A 2 .global array
A 3 .global offset
A 4 000265 .bss offset,1
A 5 00110e .text
A 6 00110e 421E MOV &offset,R14
001110 0265!
No Assembly Errors, No Assembly Warnings