The following is a very simple example. Two modules were assembled and their object module was processed by the linker. First, the two source programs are shown followed by the linker commands used to process them, followed by the linker outputs.
SAMPLE1.ASM
.chip 820 .public p1 ;public code label .extrn regdata:reg,ramdata:ram ;external data .sect otherdata,base ;local base data basedata: .dsb 1 .sect code,rom ;routine p1: ld a,regdata add a,ramdata add a,basedata ret .end
SAMPLE2.ASM
.chip 820 .public regdata,ramdata ;public data .extrn p1:rom ;external code label .sect data,reg regdata: .dsb 1 .sect moredata,ram ramdata: .dsb 1 .sect code,rom ;start of program start: jsr p1 jp . .end start
File 1 has a module name of SAMPLE1, while file 2 has one of SAMPLE2. It is important to give each assembly module a different name, since this is used in the linker load map. The default is to use the filename.
The following commands are used to generate the COFF file. Note that local option of assembler is used to show all non-public symbols in the linker cross-reference.
C:\COP8\NSASM\EXAMPLES>asmcop.exe sample1.asm /local C:\COP8\NSASM\EXAMPLES>asmcop.exe sample2.asm /local C:\COP8\NSASM\EXAMPLES>lncop.exe sample1.obj, sample2.obj /crossref
The Linker outputs the following load map(see Section 3.3 for description):
-- Range Definitions -- BASE 0000:000F ROM 0000:03FF RAM 0000:002F RAM REG REG 00F0:00FB REG 00FF:00FF -- Memory Order Map -- Code Space 0000 000B ROM Data Space 0000 0000 BASE 0001 0001 RAM 00F0 00F0 REG -- Memory Type Map -- BASE 0000 0000 [size = 0001] RAM 0001 0001 [size = 0001] REG 00F0 00F0 [size = 0001] EERAM [size = 0000] SEG [size = 0000] SEGB [size = 0000] ROM 0000 000B [size = 000C] -- Total Memory Map -- TOTAL RAM = BASE + RAM + REG + EERAM + SEG + SEGB 0000 0000 0001 0001 00F0 00F0 [size = 0003] TOTAL ROM = ROM 0000 000B [size = 000C] -- Section Table -- start end attributes Section Module 0000 0000 BASE BYTE OTHERDATA 0000 0000 SAMPLE1 0000 000B ROM BYTE CODE 0000 0002 SAMPLE2 0003 000B SAMPLE1 00F0 00F0 REG BYTE DATA 00F0 00F0 SAMPLE2 0001 0001 RAM BYTE MOREDATA 0001 0001 SAMPLE2 basedata 0000 Byte BASE Local -SAMPLE1 p1 0003 Null ROM -SAMPLE1 SAMPLE2 ramdata 0001 Byte RAM -SAMPLE2 SAMPLE1 regdata 00F0 Byte REG -SAMPLE2 SAMPLE1 start 0000 Null ROM Local -SAMPLE2 Checksum: 0x05D0 Byte Count: 0x000C (12) Output File: sample1.cof Memory Model: Small Chip: 820