Professional Documents
Culture Documents
Document version
09 February 2010
LX51
Contents
1. Introduction........................................................................................................................8
1.1 Purpose of this manual....................................................................................................................8
1.2 Scope of this manual.......................................................................................................................8
1.3 Conventions used in this manual.....................................................................................................8
1.4 Additional help or information..........................................................................................................8
2. Linker overview..................................................................................................................9
2.1 Linking.............................................................................................................................................9
2.2 Locating...........................................................................................................................................9
2.3 Segments......................................................................................................................................10
2.4 How the linker relates to other tools...............................................................................................10
2.5 Invoking and controlling the linker..................................................................................................11
2.5.1 Directives................................................................................................................................11
2.5.2 Ride7 (Raisonance Integrated Development Environment) ...................................................12
2.5.3 Command line syntax.............................................................................................................13
2.6 Input files.......................................................................................................................................13
2.6.1 Object files..............................................................................................................................13
2.6.2 Library files.............................................................................................................................13
2.7 Output files....................................................................................................................................14
2.7.1 Absolute object file..................................................................................................................14
2.7.2 Map file (Linker listing file)......................................................................................................14
2.7.3 Cross-reference file................................................................................................................15
4. Map file.............................................................................................................................22
-2-
LX51
4.1 Invocation......................................................................................................................................22
4.2 Memory model...............................................................................................................................23
4.3 Input modules................................................................................................................................23
4.4 Link map........................................................................................................................................24
4.4.1 Link map information..............................................................................................................24
4.4.2 Uses for the Link map.............................................................................................................25
4.4.3 Stack......................................................................................................................................26
4.4.4 PDATA and the external stack................................................................................................26
4.4.5 Link map title information........................................................................................................26
4.4.6 Link map examples.................................................................................................................26
4.5 Executable summary.....................................................................................................................31
4.6 Reference map..............................................................................................................................31
4.7 Symbol table..................................................................................................................................32
4.7.1 Symbol table information........................................................................................................34
4.7.2 Cross-referencing source code lines......................................................................................34
4.7.3 Locating a module’s PDATA variables....................................................................................35
4.7.4 Cross reference file................................................................................................................35
5. Segment relocation..........................................................................................................37
5.1 Segment location process..............................................................................................................37
5.2 Absolute relocation........................................................................................................................38
5.3 Ordering relocation........................................................................................................................39
5.3.1 General Memory space segment ordering..............................................................................39
5.3.2 Internal RAM segment ordering..............................................................................................39
5.4 Alignment relocation......................................................................................................................40
5.5 Memory relocation.........................................................................................................................41
5.6 Absolute segment relocation..........................................................................................................42
6. Overlaying memory..........................................................................................................43
6.1 What is overlaying?.......................................................................................................................43
6.2 Directives.......................................................................................................................................44
6.3 Map file..........................................................................................................................................44
6.3.1 Link map.................................................................................................................................44
6.3.2 Reference map.......................................................................................................................46
6.4 Function pointers...........................................................................................................................47
6.4.1 Determining the call tree.........................................................................................................47
6.4.2 Fixing the call tree...................................................................................................................47
6.4.3 Overlaying hints and tips.........................................................................................................48
-3- F
LX51
7. Code banking...................................................................................................................49
7.1 Code bank mechanism..................................................................................................................49
7.1.1 Common area.........................................................................................................................49
7.1.2 Bank switching mechanism....................................................................................................50
7.2 Code bank configuration...............................................................................................................51
7.2.1 Code bank directives .............................................................................................................51
7.2.2 Bank switching macro.............................................................................................................51
7.2.3 Assembly file..........................................................................................................................52
7.3 Map file..........................................................................................................................................53
7.3.1 Link map.................................................................................................................................53
7.3.2 Bridges...................................................................................................................................54
7.4 Locating functions and constants...................................................................................................54
7.4.1 Locating functions...................................................................................................................54
7.4.2 Locating constants..................................................................................................................54
7.5 Code banking hints and tips...........................................................................................................55
8. Flash mode......................................................................................................................56
8.1 What is Flash mode?.....................................................................................................................56
8.2 Directives.......................................................................................................................................56
8.3 Using Flash mode..........................................................................................................................56
8.3.1 Developing ROM and Flash code...........................................................................................56
8.3.2 Locking the ROM....................................................................................................................58
8.3.3 Updating the Flash Code........................................................................................................58
9. Kernel...............................................................................................................................59
9.1 Linking ..........................................................................................................................................59
9.2 Configuration.................................................................................................................................59
9.2.1 Kernel model..........................................................................................................................59
9.2.2 Time.......................................................................................................................................59
9.2.3 Clock......................................................................................................................................59
9.2.4 Dividers...................................................................................................................................60
-4-
LX51
-5- F
LX51
-6-
LX51
16. Conformity....................................................................................................................104
17. Glossary.......................................................................................................................105
18. Index............................................................................................................................106
19. History..........................................................................................................................107
-7- F
1. Introduction LX51
1. Introduction
The Raisonance 8051 Development Kits are a complete solution to creating software for the 8051
family of microcontrollers. The Development Kits comprise many different tools that allow projects
ranging from simple to highly complex to be developed with relative ease.
-8-
LX51 2. Linker overview
2. Linker overview
Before explaining what a Linker does, it is necessary to explain what a compiler and assembler do.
A compiler and assembler take a file containing symbolic information that represents source code.
From that source code a file is generated called an object file. This object file contains a compiled or
assembled form of the source code along with a list of the symbols used.
For example, let’s say we wrote the following C source file:
unsigned char x;
extern unsigned char y;
void main(void)
{
x = 1;
y = 2;
while(1);
}
The object file contains binary code to assign values to the variables x and y and then loop forever.
In addition a symbol table lists the variables x and y and the function main. However the locations of
x, y and main will not be known.
• In place of the addresses in the code will be place holders for the addresses.
• The code and variable are called “relocatable” as they may be located anywhere.
• Before the code can be executed and the variables used, they must be located at specific
addresses in memory.
Let's look more closely at the variable y. The C code simply tells the C Compiler that the variable is
declared elsewhere and that we wish to use the same variable y. Another C source file will declare the
variable y and will be compiled into a separate object file, however that object file is independent of this
object file. Somehow the two must be combined so the same variable y is used in both.
The two functions of the Linker are:
• locating variables and code at specific addresses,
• linking separate object files together, resolving the symbol tables in each.
In general the data represented by an object file is called a “module”.
2.1 Linking
The Linker accepts a list of object files (each containing a module).
The symbol table from each one is analysed to find out if a variable that is used in one module is
declared in another. When a match is found then the two symbols are combined into the same symbol.
This process is called “resolving”.
The same process is used for function calls. If a function or routine call is made in one module to a
function or routine declared in another module, then the symbols are resolved.
2.2 Locating
Once all the symbols have been resolved the Linker locates code and variables at specific locations,
replacing the placeholders with real addresses. Not all code and variables are relocatable however.
Some variables may have been declared using:
at 0x12 unsigned char foo;
Which means the variable foo must be located at address 12H, or otherwise generate an error.
-9- F
2. Linker overview LX51
An example of code that is not relocatable is an interrupt vector. Variables or code that are not
relocatable are called “absolute” code or variables.
Before the Linker locates the relocatable variables and code, it reserves space for the absolute
variables and code. It then locates the relocatable variables and code in the spaces around the
absolute items. The Linker therefore has to use an algorithm to generate the most efficient memory
usage.
It is also possible to use the Linker’s controls to specify that specific relocatable items must be located
at specific addresses. This method is used to locate functions.
Other Linker controls are provided to direct the Linker in general ways on how the relocatable variables
and code should be located.
2.3 Segments
Rather than the Linker locate individual variables and lines of code at a time, the compiler splits the
source files up into segments. Assembly code may be manually split up into segments.
Each segment is either absolute or relocatable and contains either multiple lines of code or multiple
variables in the same memory space. Once the segment has been located the symbol table for all the
symbols inside the segment is updated with the locations of the symbols.
Segments allow the Linker to operate faster and more efficiently and allow it to generate useful
information that may easily be read and understood by the user.
Segments are discussed in more detail in chapter 4.
.c file .a51
file
Compiler Assembler
.lib file
.lib file
.aof file
Object-HEX
Converter
.hex file
RIDE Simulator/Debugger
- 10 -
LX51 2. Linker overview
The Linker accepts object files generated by the compiler or assembler. Each object file contains
absolute segments and relocatable segments.
The Linker also accepts library files. Library files contain one or more object files inside them.
Libraries can be thought of as packages or collections of object files rolled up into one new file.
A tool called the Library manager accepts object files generated by the compiler and assembler and
generates library files. The library files are then used in another project.
The absolute object file generated by the Linker is either used by a simulator/debugger or converted
into an Intel Hex file for programming into a device.
2.5.1 Directives
The Linker is a command line executable program that may be executed by entering its name – LX51 –
at the DOS prompt. Here is a sample output:
C:\>LX51
MS-DOS MCS-51 CODE BANKING LINKER/LOCATOR LX51 V5.01.02
Copyright (c) Raisonance S.A. 1987-2000. All rights reserved
It is useful for the user to be able to control the Linker and direct how it should operate to generate the
desired results for a particular application.
The executable LX51 accepts controls on the command line called “Directives” that instruct the Linker
how to operate. For example:
RAMSIZE(256)
Informs the linker that the 8051 being targeted has 256 bytes of internal RAM. The directive would be
used on the command line as follows:
LX51 foo.obj TO(foo) RAMSIZE(256)
- 11 - F
2. Linker overview LX51
In Ride7 under the Linker options there is a field to enter the size of internal RAM. This field has the
same effect as the RAMSIZE directive, and it can be imagined that when Ride7 invokes the Linker it
constructs a command line with RAMSIZE on it, specifying the value entered into the field (it doesn’t
quite work that way, however the result is the same).
Ride7 does not provide graphical equivalents of all the Linker directives however. For situations when
there are no graphical equivalents, the directives can be entered into the “Additional options” field
under the Linker options exactly as if they were on a command line.
Appendix B contains tables indicating which Linker directives are used for each control in Ride7.
- 12 -
LX51 2. Linker overview
specialdirectiveslist:
a space separated list of special directives. The directives may be listed in any order. If each directive
is not explicitly listed then defaults will be used for the missing directives.
Only the following two directives are special directives:
-C
objectfilelist:
a comma separated list of object files and library files to be linked together.
directiveslist:
a space separated list of directives. The directives may be listed in any order. If each directive is not
explicitly listed then defaults will be used for the missing directives. Please refer to the directives
reference in Appendix A for the default setting for each directive. Special directives may not be listed in
this section of the command line.
commandfile:
a plain text file that contains the command line arguments. I.e. the special directives, object files and
directives. The arguments may be split into multiple lines by adding an ampersand (&) to the end of the
lines. The ampersand allows to add comments after it on the line.
Command line examples:
LX51 -C test.obj, foo.lib TO(test.aof) RS(128) IX
LX51 @test.cmd
Where test.cmd contains:
-C test.obj, foo.lib &
TO(test.aof) & comments: this allows to specify the .aof name
RX(128) IX
- 13 - F
2. Linker overview LX51
There are various controls (called Directives) that may be used to control the contents of the map file:
Map file directive Description
LINES (LI) Insert source code lines into the symbol table.
MAP (MA) Include a Link map in the map file.
NOLINES (NOLI) Omit source code lines from the symbol table.
NOMAP (NOMA) Omit a Link map from the map file.
NOPRINT (NOPR) Stops the Linker from generating a map file.
NOPUBLICS (NOPU) Omit public symbols from the symbol table.
NOSYMBOLS (NOSB) Omit local symbols from the symbol table.
PRINT (PR) Instructs the Linker to generate a map file.
PUBLICS (PU) Insert public symbols into the symbol table.
SYMBOLS (SB) Insert local symbols into the symbol table.
- 14 -
LX51 2. Linker overview
The map file is sometimes referred to as the Linker listing file. However this manual refers to the file as
the map file to differentiate it from the listing files generated by the compiler and assembler.
- 15 - F
3. Modules and segments LX51
Compiler or Assembler
Modul
Segment Segment e
* optionally
included
3.1 Modules
A single source file is either compiled or assembled to generate an object file, which contains data
collectively referred to as a Module.
The Module has a name that is derived from the source file name. For example the source file FOO.C
will generate a module with the name FOO.
Note: Each Module in a project must have a unique name. This creates implications for the source file
names used in a project. For example:
FOO.C
FOO.A51
Both generate Modules with the name FOO. The Module names will therefore not be unique in the
project. The result is that a project cannot have two source files with the same file name regardless of
the extension used.
This problem can be avoided by using the assembler’s NAME directive, which allows the Module name
to be explicitly chosen by the user. The Module name can be unrelated to the file name.
Another implication is that debugging is made easier if source files have descriptive file names. It will be
clear what function a particular module has.
- 16 -
LX51 3. Modules and segments
- 17 - F
3. Modules and segments LX51
3.2 Segments
The code and data generated by a source file is split up into segments. As already explained, these
segments, along with a symbol table and optional debugging information are referred to as a module.
But how is the source code split up into segments?
From each source file there will be created one segment for each function and one segment for each
for of the memory spaces DATA, IDATA, BIT, CODE, PDATA and XDATA, providing there are
variables in a particular memory space.
For example, if a module has the following:
• Two functions foo and bar
• Three variables in DATA memory
• Two variables in XDATA memory
Then the following four segments will be created:
• One for the function foo
• One for the function bar
• One for the variables in DATA memory
• One for the variables in XDATA memory
Note: Absolute segments do not have names because the OMF-51 file format used for the object files
does not allow names for absolute segments.
CODE segments fall into two categories, executable and non-executable. The non-executable code
segments have the same naming format as other non-executable segments containing variables in the
other memory spaces. Executable code segments have a different naming format.
Executable code segment names have the following format:
?PR?symbolicfunctionname?modulename
Where symbolicfunctionname is a symbol used to represent the function throughout the Linker
map file and Cross Reference file (described in chapter 4).
It has the following format:
[_|?]functionname
- 18 -
LX51 3. Modules and segments
Where:
• “_” prefix means a non-re-entrant function whose parameters are passed in registers
• “?” prefix means a re-entrant function whose parameters are passed in registers
For example the following functions declared in the module CRUNCH:
void apple(void) { ; }
void banana(unsigned char b) { ; }
void orange(void) reentrant { ; }
void pear(unsigned char p) reentrant { ; }
Generate the following segment names:
?PR?apple?CRUNCH
?PR?_banana?CRUNCH
?PR?orange?CRUNCH
?PR??pear?CRUNCH
Non-executable segment names have the following format:
?memoryspace?module name
- 19 - F
3. Modules and segments LX51
Module Module
Linker
.aof
Module
As shown in the diagram, whether the input files are object files or library files, the result is that a
collection of modules is supplied to the Linker.
The Linker then takes the symbol tables of each module and resolves them. The relocatable segments
are located according to the rules and algorithms used by the Linker.
Generated by the Linker is an Output module, stored in a absolute object file (extension .aof). All the
segments in the Output module are absolute. In addition all the symbols in the symbol table have fixed
addresses. As in the case for the Input modules, the debugging information is optional.
The name of the Output module is by default the same as the name of the first module supplied to the
Linker. However the Linker NAME directive allows the name of the Output module to be selected by the
user. This can be useful when debugging or simulating applications.
- 20 -
LX51 3. Modules and segments
- 21 - F
4. Map file LX51
4. Map file
The map file is generated by the Linker and contains a wealth of information on what the Linker actually
did to the segments in the Input modules. Understanding the map file can speed up development time
and greatly improve the chances of a project’s success.
The map file usually has the file name extension .m51 and is a plain text file. It is generated during the
Linker’s execution and placed in the project directory.
The PRINT and NOPRINT directives instruct the Linker to either generate or not generate a map file
respectively. The default setting is for the Linker to generate the map file and it is recommended that
the map file is always generated.
The map file contains the following sections of information in order from start to finish. Each section is
discussed in detail in the remainder of this chapter.
4.1 Invocation
The first item in the map file shows how the Linker was called on the command line, or if Ride7 was
used to call the Linker, then how it could have been called on the command line to achieve the same
result. This is very useful in determining if a mistake was made with the Linker options in Ride7 or on
the command line, or if finding out if a particular directive was or was not used.
It is also useful for finding out which directives are controlled by specific Linker options in Ride7.
Here is an example:
LX51 c:\temp\testproject\main2&
.obj,c:\temp\testproject\main.obj TO(c:\temp\testproject\project.AOF) PR(c:\t&
emp\testproject\project.m51) PW(80) RS(128) RSI(4) IX
The ampersands (&) at the end of some of the lines indicate that an argument has been split across
that line and the following line for the sake of formatting the map file.
The above example clearly shows the paths and file names of the object files that were linked together,
the location and file name of the absolute object file generated, the location and file name of the map
file, and the directives used.
When debugging an application the command line invocation makes it possible to look up all the
directives used in the reference section of this manual, to ensure that the Linker is being invoked
correctly.
- 22 -
LX51 4. Map file
- 23 - F
4. Map file LX51
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0001H UNIT ?DT?MAIN2
0009H 0017H *** GAP ***
BIT 0020H.0 0000H.2 UNIT ?BI?MAIN2
0020H.2 001FH.6 *** GAP ***
DATA 0040H 0001H ABSOLUTE
IDATA 0041H 0001H * * STACK * * _STACK
* * * * * * * PDATA/XDATA M E M O R Y * * * * * * *
XDATA 0000H 0001H UNIT ?XD?MAIN2
PDATA 0001H 0001H INPAGE ?PD??C_XSTACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0003H UNIT ?PR?bar?MAIN2
CODE 0006H 0002H UNIT ?PR?MAIN
0008H 0003H *** GAP ***
CODE 000BH 0003H ABSOLUTE
CODE 000EH 000FH UNIT ?PR?C51_STARTUP?
CODE 001DH 0005H UNIT ?PR?isr?MAIN
CODE 0022H 0004H UNIT ?PR?foo?MAIN
CODE 0026H 0005H UNIT ?PR?main?MAIN
- 24 -
LX51 4. Map file
- 25 - F
4. Map file LX51
4.4.3 Stack
The stack segment is always located last in the IDATA memory space and has the special segment
name _STACK.
However, you may have noticed that the stack segment is only one byte in size. The reason for this is
because the stack segment only represents the stack pointer’s initial location, not the whole stack.
Just before the main function is executed, the system stack pointer will be set to the address of the
stack segment.
As data is pushed onto the stack the stack pointer moves upwards through the IDATA space. If it ever
goes beyond 7FH (for 128 bytes of IDATA) or FFH (for 256 bytes of IDATA) it will either access
gibberish or wrap around to 00H. In either situation the application will quickly crash.
In the example Link map the stack segment is located at 0041H in IDATA. At first it appears that the
rest of IDATA (0042H – 007FH or 00FFH) is free for use by variables or pointers, perhaps as a scratch
space. Wrong!
Let's say that the biggest the stack will ever get at any point in time is 20H bytes. If any location
between 0042H and 0042H + 20H – 1 = 0061H is modified, there is a big risk that data on the stack will
be corrupted resulting in the application crashing.
This has other implications. Let's say your microcontroller has 128 bytes of RAM and the Link map
looks like the example shown. Also let's say that your application at most requires 20H bytes for the
stack. This leaves 0080H – 0041H – 0020H = 1FH bytes of IDATA that is never used.
Now let's imagine that you make a modification to the application. The modification includes an array
that is 11H bytes in size. The result of the modification means that the stack could now become 30H
bytes in size at any point in time. Now the stack will be located at 0041H + 11H = 0052H. The amount
of IDATA that will never be used is now: 0080H – 0052H – 0030H = -2 bytes!
At some point the stack will overflow crashing the application. The Link map does not inform you of this
fact directly, only indirectly.
Note: Both PDATA variables and the external stack have to share the same 256 byte page. However
PDATA variables are located before the external stack, therefore it may not be possible to allocate as
much space as desired for the external stack. For example if the external stack is set to a size of 256
bytes and there are four bytes of PDATA variables in the project, then the external stack will be 252
bytes in size. If this causes a problem for your project then move some variables from PDATA to another
memory space to free up more of the page.
- 26 -
LX51 4. Map file
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0001H UNIT ?DT?MAIN2
0009H 0037H *** GAP ***
DATA 0040H 0001H ABSOLUTE
IDATA 0041H 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
0000H 8000H *** GAP ***
CODE 8000H 0003H ABSOLUTE
CODE 8003H 0003H UNIT ?PR?bar?MAIN2
CODE 8006H 0002H UNIT ?PR?MAIN
8008H 0003H *** GAP ***
CODE 800BH 0003H ABSOLUTE
CODE 800EH 000FH UNIT ?PR?C51_STARTUP?
CODE 801DH 0005H UNIT ?PR?isr?MAIN
CODE 8022H 0004H UNIT ?PR?foo?MAIN
CODE 8026H 0005H UNIT ?PR?main?MAIN
As the Link map makes clear, there is a gap starting at 0000H in CODE space, 8000H bytes in size.
Therefore the gap covers locations 0000H to 7FFFH inclusive.
Note: By using the ABSOLUTECODEOFFS directive, the reset vector and interrupt vectors can also be
located starting at 8000H. So the interrupt vector previously at 000BH is now located at 800BH. This is
useful if the physical memory device exists at 8000H, however is mapped to logical addresses starting at
0000H.
- 27 - F
4. Map file LX51
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0001H UNIT ?DT?MAIN2
0009H 0007H *** GAP ***
REG 0010H 0008H ABSOLUTE "REG BANK 2"
REG 0018H 0008H ABSOLUTE "REG BANK 3"
IDATA 0020H 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0003H UNIT ?PR?bar?MAIN2
CODE 0006H 0002H UNIT ?PR?MAIN
0008H 0003H *** GAP ***
CODE 000BH 0003H ABSOLUTE
CODE 000EH 000FH UNIT ?PR?C51_STARTUP?
CODE 001DH 0008H UNIT ?PR?isr?MAIN
CODE 0025H 000BH UNIT ?PR?foo?MAIN
CODE 0030H 0005H UNIT ?PR?main?MAIN
Notice that the Linker has inserted a DATA segment into the eight byte space between Register Banks
zero and two to optimize memory usage and leave as much room as possible free for the stack.
- 28 -
LX51 4. Map file
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0001H UNIT ?DT?BANK?SWITCH
DATA 0009H 0001H UNIT ?DT?MAIN2
IDATA 000AH 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0035H INBLOCK ?BANK?SWITCH
CODE 0038H 000FH UNIT ?PR?C51_STARTUP?
CODE 0047H 0002H UNIT ?PR?MAIN
CODE 0049H 0004H UNIT ?PR?foo?MAIN
CODE 004DH 0005H UNIT ?PR?main?MAIN
* * * B A N K N U M B E R 0 * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 8000H 0002H UNIT ?PR?bank2?MAIN3
CODE 8002H 0004H UNIT ?PR?_crunch?MAIN3
* * * B A N K N U M B E R 1 * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 8000H 0003H UNIT ?PR?bar?MAIN2
The first CODE memory section shows the CODE segments that are located in the common area.
The other two CODE memory sections are listed under BANK NUMBER 0 and BANK NUMBER 1 and
show the CODE segments that are located in code banks zero and one respectively. The code banks
start at location 8000H.
- 29 - F
4. Map file LX51
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0005H UNIT ?Reserve?DATA
DATA 000DH 0001H UNIT ?DT?BANK?SWITCH
DATA 000EH 0001H UNIT ?DT?MAIN2
000FH 0011H *** GAP ***
DATA 0020H 0008H BITADDRESSABLE ?Reserve?BDATA
BIT 0028H.0 0000H.4 UNIT ?Reserve?BIT
0028H.4 0000H.4 *** GAP ***
IDATA 0029H 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0001H UNIT _C_INITD?CD
CODE 0004H 0072H UNIT ?PR?C51_STARTUP?
CODE 0076H 0026H UNIT ?BANK?SWITCH
CODE 009CH 0002H UNIT ?PR?MAIN
CODE 009EH 0004H UNIT ?PR?foo?MAIN
CODE 00A2H 0005H UNIT ?PR?main?MAIN
* * * F L A S H A R E A * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 8000H 0009H ABSOLUTE ?FLASH?TABLE_00?
CODE 8009H 0002H UNIT ?PR?bank2?MAIN3
CODE 800BH 0004H UNIT ?PR?_crunch?MAIN3
CODE 800FH 0003H UNIT ?PR?bar?MAIN2
The CODE memory section listed under FLASH AREA shows which CODE segments will be located in
Flash memory.
The Flash option also allows DATA memory to be reserved. Special absolute segments are generated
to ensure those memory areas are not used with the following segment name format:
?Reserve?memorytype
- 30 -
LX51 4. Map file
The values are given in the following format: bytes.bits, for example 18H.4 and 24.4 both mean 24
bytes and four bits.
The executable summary however, does not always give a full picture of the memory requirements of
an application. When code banking is used the sizes of all the code segments in all the code banks
used along with the common area are totaled and presented in the executable summary, even though
some segments occupy the same locations, just in different code banks.
In addition, the summary does not include the system stack, as the compiler is unable to determine
how much stack space would be required by the application.
- 31 - F
4. Map file LX51
Note: Regular symbols include static symbols and automatic symbols. Due to limitations in the OMF-51
file format used, the information that differentiates between static and automatic symbols is lost. Hence
both symbols are referred to at the Linking stage as Regular symbols. This is also the reason why the
symbol type is listed in the table rather than the symbol class. Because some information has been lost,
it cannot be referred to as the class, only as the symbol type, to emphasize the difference between the
information in the compiler generated Symbol Table and the Linker generated Symbol Table.
- 32 -
LX51 4. Map file
- 33 - F
4. Map file LX51
Name Symbol name for Public and Regular Symbols. Source code line number for source
code lines.
- 34 -
LX51 4. Map file
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0077H 0014H UNIT ?PR?foo?MAIN
All the symbols located from X:0000H to X:0002H are PDATA variables declared in the module main.
Any other symbols located in XDATA, not inside the XDATA segment are XDATA variables.
Note: This same method may be used to find the location and order of variables in any segment.
- 35 - F
4. Map file LX51
The Cross Reference file contains one table, which looks like the following example:
For example the symbol bar (which is a function) is declared and possibly used in the module MAIN2
and used in the module MAIN. This is indicative of an inter-Module function call.
If Code Banking is being used then CODE symbols not located in the Common Area will be indicated
by the word “BANK” at the start of the line in the Cross Reference file.
- 36 -
LX51 5. Segment relocation
5. Segment relocation
There are two kinds of segments, relocatable and absolute.
• Absolute segments must be located at a location determined by the compiler or assembler.
• Relocatable segments are located automatically by the Linker.
The Linker provides a set of directives that enable the user to direct how the Linker should locate
relocatable segments. These directives provide different types of constraints on where the Linker may
locate the segments.
The following table shows the types of Relocation constraints possible:
Restrictiveness Constraint type Directives
Most restrictive Absolute CODE, DATA, XDATA, BIT, IDATA
Ordering CODE, DATA, XDATA, BIT, IDATA, PRECEDE, STACK
Alignment PAGE
Least Restrictive Memory CODE, DATA, XDATA, BIT, IDATA, PDATA, STARTCODE
It is also possible to instruct the Linker to locate absolute segments at an offset using the
ABSOLUTECODEOFFS and MOVEABSCODE directives.
This chapter will discuss the process the Linker goes through to locate segments. It will then highlight
the various methods of relocating segments and how to double-check that the memory map for a
project is right.
- 37 - F
5. Segment relocation LX51
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
IDATA 000FH 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0066H UNIT ?PR?C51_STARTUP?
CODE 0099H 0008H UNIT ?PR?main?MAIN
CODE 00A1H 0005H UNIT _C_INITD?CD
00A6H 025AH *** GAP ***
CODE 0300H 002DH UNIT ?PR?foo?MAIN
Notice that the segment is located at 300H, leaving a gap in the CODE space.
It is possible to absolutely locate more than one segment at a time.
For example:
XDATA(?XD?SIFT(0x4000),?XD?BRCH(0x5000))
will locate the segment ?XD?SIFT at 4000H and the segment ?XD?BRCH at 5000H.
This method is useful for locating functions at specific locations, perhaps so they are physically stored
in a particular memory device that could be replaced or erased in an upgrade.
It is also useful for locating variables at specific locations, however the at keyword or using pointers is
usually more preferable as it makes it clearer in the code what is going on.
Note: It is not possible to relocate the PDATA segment as it must always fit into a single page starting at
the base address of PDATA – specified using the PDATA directive.
For a complete description of the CODE, DATA, IDATA, BIT and XDATA directives please refer to the
directive reference in Appendix A.
- 38 -
LX51 5. Segment relocation
Note: The ?ID?SIFT segment is located just below the base of the stack.
- 39 - F
5. Segment relocation LX51
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0004H UNIT ?DT?MAIN
IDATA 0010H 0001H * * STACK * * _STACK
* * * * * * * PDATA/XDATA M E M O R Y * * * * * * *
XDATA 0000H 0001H UNIT ?XD?MAIN2
XDATA 0001H 0004H INPAGE ?C_XSTACK
0005H 00FBH *** GAP ***
XDATA 0100H 0001H PAGE ?XD?MAIN
Note: The ?XD?MAIN segment has been located at 100H, leaving a gap in the XDATA memory space.
- 40 -
LX51 5. Segment relocation
Note: The XDATA directive affects PDATA variables as well. However if the PDATA directive is used to
specify a start address for the PDATA memory space then the PDATA segment is located starting at that
address.
- 41 - F
5. Segment relocation LX51
* * * * * * * PDATA/XDATA M E M O R Y * * * * * * *
0000H 1000H *** GAP ***
XDATA 1000H 0001H UNIT ?XD?SIFT
XDATA 1001H 0001H UNIT ?XD?MAIN2
XDATA 1002H 0001H UNIT ?XD?MAIN
1003H 0FFDH *** GAP ***
XDATA 2000H 0004H INPAGE ?C_XSTACK
Note: The STARTCODE directive allows the start address for the CODE memory space to be specified,
duplicating that functionality of the CODE directive. However it cannot be used to locate segments or
specify segment ordering.
- 42 -
LX51 6. Overlaying memory
6. Overlaying memory
- 43 - F
6. Overlaying memory LX51
Once the Linker determines the call tree it can work out if a function’s automatic variables may be
overlaid with the automatic variables of other functions. For example from the diagram above the
Linker can work out the following rules:
1. Variables in foo and bar can be overlaid
2. Variables in foo and baz can be overlaid
3. Variables in main and foo cannot be overlaid
4. Variables in main and bar cannot be overlaid
5. Variables in bar and baz cannot be overlaid
Because variables in bar and baz cannot be overlaid, variables in foo can either be overlaid with
variables in bar or baz, but not both. The Linker then has to work out which one will produce the
optimum RAM usage.
Note: Not all automatic variables are overlaid. There are a number of reasons for this:
1. There may not be any other automatic variables to overlay with
2. Overlaying particular automatic variables may not generate the optimum RAM usage
3. The automatic variables are located entirely in registers
6.2 Directives
The following table summarizes the directives involved in overlaying variables.
Overlay directive Description
NOFCTPTRMANAG (NOFPM) Function pointers will not be automatically managed for the overlay
process.
NOOVERLAY (NOOL) Do not overlay automatic variables.
OVERLAY (OL) Overlays automatic variables if possible and controls overlaying.
SEGMENTOVERLAY (SO) Manual overlay of specified segments
A more detailed description of these directives may be found in Appendix A.
The NOFCTPTRMANAG and OVERLAY directives are discussed in section Function Pointers.
- 44 -
LX51 6. Overlaying memory
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0003H OVERLAID UNIT _DGROUP00_
DATA 000BH 0001H UNIT ?DT?MAIN
IDATA 000CH 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0001H UNIT _C_INITD?CD
CODE 0004H 016BH UNIT ?PR?LIB51
CODE 016FH 0072H UNIT ?PR?C51_STARTUP?
CODE 01E1H 0005H UNIT ?STR?MAIN
CODE 01E6H 0017H UNIT ?PR?foo?MAIN
CODE 01FDH 0017H UNIT ?PR?bar?MAIN
CODE 0214H 0008H UNIT ?PR?main?MAIN
The overlaid variables are located in a segment with a special name _DGROUP00_. The name
indicates it is group 00 of overlaid variables in DATA memory. Notice that the size of the group is three
bytes – the size of the largest overlaid variable.
The Relocation name is “OVERLAID UNIT” and not only UNIT
If we look at the symbol table for the variables a and b we see the following:
VALUE TYPE NAME
----- ---- ----
D:0008H SYMBOL a
D:0008H SYMBOL b
Both variables are located at the same address, 8H in DATA memory, which corresponds to the
_DGROUP00_ segment.
- 45 - F
6. Overlaying memory LX51
- 46 -
LX51 6. Overlaying memory
apple()
orange()
So, this is good in that Memory Overlaying still works when function pointers are used, however the
downside is that if a large number of function pointers are used, then a sizeable section of the
application will not be able to overlay variables and therefore use more RAM.
If RAM usage is critical and solving the overlaying problem is the only solution then the directive
NOFCTPTRMANAG may be used. This has the effect of ignoring indirect function calls when determining
the Call Tree. The result is that variables in many functions may now be overlaid, however because the
Call Tree is now incorrect, there is the possibility that variables may be corrupted.
The only solution to this is to manually fix the Call Tree using the OVERLAY directive.
apple()
Lets assume that the function apple does not call foo or bar directly either.
Therefore the variables in apple, foo and bar could be overlaid, but because of the Linker’s
conservative approach to overlaying with function pointers they are not.
- 47 - F
6. Overlaying memory LX51
- 48 -
LX51 7. Code banking
7. Code banking
An 8051 has a limit of 64Kb Code memory. Often an application requires more than 64Kb, for example
if large constant look-up tables are required.
The Linker includes a feature called Code Banking (also referred to as Bank Switching) that allows the
amount of Code memory to be increased up to 4Mb.
How is this achieved?
n
This diagram shows the memory
… arrangement:
2 • The address space from b to FFFFH
1 is overlaid with Code Banks.
FFFF
0 Code Banks • At any one time a single Code bank
H is selected and therefore available at
addresses b to FFFFH.
For example, if there are 4 Code Banks and
Bank 1 was selected, banks 0, 2 and 3
would not be accessible.
Therefore at any point in time the 8051 can
b only “see” 64Kb of the Code memory.
Common
0000H
Area
- 49 - F
7. Code banking LX51
- 50 -
LX51 7. Code banking
22000H
Common
20000 Area
H 1
Code Bank 1
12000H
Common
10000H Area
0
Code Bank 0
02000H
Common
Area
- 51 - F
7. Code banking LX51
As can be seen in the diagram, the Common Area is duplicated in every 64K block of memory.
When this arrangement is used, selecting a Code Bank can be thought of as selecting a particular 64K
“window” which the microcontroller can access. In each 64K “window” there must be a copy of the
Common Area so the code and data contained in it is always accessible.
This raises the important point that the Common Area must be as small as possible in order to reduce
the amount of memory that is wasted overall through duplication of the Common Area.
• Generating additional address lines is more efficient usage for precious port pins,
• Generating chip select signals directly removes the need for additional decoding hardware.
However chip select signals are only really useful if more than one memory device is used.
In either case, the macro allows complete flexibility and customization as to how the bank switching is
performed.
By default the macro is:
mov A,?B_CURRENTBANK
anl P1,#0f8h
orl P1,A
The default macro sets pins P1.0, P1.1 and P1.2 to indicate the current code bank, acting as additional
upper address lines. For example:
P1.7 P1.0
xxxxx000 - selects code bank 0
xxxxx010 - selects code bank 2
xxxxx111 - selects code bank 7
Note: The L51_BANK.A51 file should never be edited if Ride7 is being used. Only edit the file if you are
using the command line tools.
Also note that when using Ride7 a copy of the file is automatically added to the project when Code
Banking is selected.
- 52 -
LX51 7. Code banking
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0001H UNIT ?DT?BANK?SWITCH
DATA 0009H 0001H UNIT ?DT?BANK2
DATA 000AH 0001H UNIT ?C_SPX
IDATA 000BH 0001H * * STACK * * _STACK
* * * * * * * PDATA/XDATA M E M O R Y * * * * * * *
PDATA 0000H 0001H INPAGE ?C_XSTACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0056H INBLOCK ?BANK?SWITCH
CODE 0059H 000FH UNIT ?PR?C51_STARTUP?
CODE 0068H 0005H UNIT ?PR?main?MAIN
* * * B A N K N U M B E R 1 * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 2000H 0004H UNIT ?PR?bank1func?BANK1
* * * B A N K N U M B E R 2 * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 2000H 0003H UNIT ?PR?bank2func?BANK2
Code Memory is divided up into three separate sections; the second one under the heading “Bank
Number 1” and the third under “Bank Number 2”.
The first Code Memory section is the Common Area. The other two sections are code banks, and it
can be seen that the Code Banks in this example start at location 2000H.
- 53 - F
7. Code banking LX51
7.3.2 Bridges
The bridges created by the Linker are listed in the map file. The following is an example that matches
the Link map shown in this section:
BRIDGES CREATED :
_bank1func (004AH) ?PR?bank1func?BANK1[1]
_bank2func (0054H) ?PR?bank2func?BANK2[2]
Each line contains four pieces of information:
• The first item is the bridge name, and also the symbol used to identify the start address of the
bridge.
• The second item is the address of the bridge. Note that by cross-referencing these locations
with the Link map it can be seen that both bridges are contained in the segment ?BANK?
SWITCH.
• The third item is the segment name containing the function that the bridge calls.
• The fourth and final item is the code bank number that the segment is located in.
- 54 -
LX51 7. Code banking
Note: The function and the constant code are located in the same Code Bank.
Large Look-up tables may not fit into a single Code Bank, however, using “access functions” it is easy
to split the table up into sections.
For example, a look-up table 10000H in size, fitting into Code Banks 8100H in size:
Bank 1:
const unsigned char code table_b1[0x8000] = {0, 1, 2};
Note: During assembly, the Linker cannot determine that bridges should not be generated for constants
in Code memory, and generates bridges for all public symbols in Code memory. This results in wasted
memory. The NOBRIDGE directive may be used to avoid this. Refer to Appendix A for a full description of
the directive.
- 55 - F
8. Flash mode LX51
8. Flash mode
8.2 Directives
The following table summarizes the directives used with Flash Mode:
Flash Directive Description
FLASH (FLS) Specifies the start address of Flash memory and the object files to locate in Flash.
FLASHBANKAREA Specifies the start and end address range which Flash banks occupy.
(FLSBANKAREA)
FLASHNAME (FLN) Specifies the file to store Flash information.
NOSTATVARROM Locates the initial values of static variables in Flash rather than ROM.
(NOSTATVARROM)
REFLASH (REFLS) Specifies the file containing Flash information in locked mode.
RESERVE (RES) Reserves memory for future enhancements.
STATVARROM Locates the initial values of static variables in ROM rather than Flash.
(STATVARROM)
- 56 -
LX51 8. Flash mode
A typical Link map will look like the following (please see Chapter 5 for a complete description of the
map file and its contents):
LINK MAP OF MODULE: C:\TEMP\FIXUPTEST\FIXUPTEST.AOF (BAR)
* * * F L A S H A R E A * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 8000H 0009H ABSOLUTE ?FLASH?TABLE_00?
CODE 8009H 0003H UNIT ?PR?bar?BAR
CODE 800CH 0003H UNIT ?PR?foo?FOO
CODE 800FH 0001H UNIT _C_INITD?CD
There are several items of note in the Link map:
• The Flash area is shown as a separate code memory area starting at 8000H, where the
segments to be located in Flash are listed.
• The segment ?FLASH?TABLE_00? Contains a symbol table that matches up function names
and symbols with addresses. Any calls to functions in Flash memory result in the address of the
function being obtained from the table. This allows the functions in Flash to change locations
while the application will still function.
• The segment _C_INITD?CD contains the initial values of the static variables in the application.
Because this segment is located in Flash at a future date the Flash may be changed to include
additional initialized static variables. The directives NOSTATVARROM and STATVARROM
control the location of this segment – either in Flash or ROM.
• The segments ?Reserve?BDATA, ?Reserve?BIT and ?Reserve?DATA are special segments
that reserve bit-addressable data memory and regular data memory for use in future updates of
the Flash code. The amount of memory to reserve of each type is controlled using the
RESERVE directive.
Two Hex files are generated:
• projectname.hex – ROM Code
• projectname.he0 – Flash Code
- 57 - F
8. Flash mode LX51
* * * * * * * DATA/IDATA M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0001H # UNIT ?DT?MAIN
DATA 0009H 0001H UNIT ?DT?BAR
DATA 000AH 0001H UNIT ?DT?FOO
IDATA 000BH 0001H * * STACK * * _STACK
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 0000H 0003H # ABSOLUTE
CODE 0003H 0072H # UNIT ?PR?C51_STARTUP?
CODE 0075H 0008H # UNIT ?PR?main?MAIN
* * * F L A S H A R E A * * *
* * * * * * * CODE M E M O R Y * * * * * * *
CODE 8000H 0012H ABSOLUTE ?FLASH?TABLE_00?
CODE 8012H 0003H UNIT ?PR?bar?BAR
CODE 8015H 0003H UNIT ?PR?foo?FOO
CODE 8018H 0001H UNIT _C_INITD?CD
In the table some of the segments feature a “#” just before the Relocation type. These segments are
locked against further change.
Notice that the reserved segments have disappeared leaving free memory that may now be used.
It is also possible to add new source files to the project. The generated modules will automatically be
stored in the Flash memory.
- 58 -
LX51 9. Kernel
9. Kernel
The Kernel is a Real-Time Operating System (RTOS) that enables functions to be declared as tasks,
providing a method to write real-time multitasking systems.
The Kernel provides time slicing capabilities that have been optimized for the 8051 architecture.
Each task can be assigned a priority and when a task is running it is unaware of other tasks in the
system.
The Kernel is provided in the form of a library that is linked in with an application, generating a single
absolute object file, and therefore a single Hex file.
A header file must be included in the source code to gain access to the Kernel’s functions and
services.
9.1 Linking
The Kernel is linked in with a project by choosing Options | Project Properties, expanding the LX51
part of the tree and selecting KR-51 Kernel.
9.2 Configuration
The window allows various configuration options to be set. Ride7 generates a special object file
containing symbols whose values correspond to the settings. The object file is passed to the Linker and
the Kernel code then makes use of the symbols for configuration. This means that it is not possible to
Link a project with the Kernel using the Command Line. Instead Ride7 must be used.
Selection of the model depends on the applications requirements and XDATA memory available.
Each model may be used with or without debug capabilities and semaphores.
Using either option slows down execution of the Kernel and requires additional RAM, however debug
capabilities provide a more robust environment, and semaphores may be used to control access to
global variables and peripherals.
9.2.2 Time
When the option Use the automatic definitions is selected then the clock and dividers settings in the
window will be used. If it is not selected then the settings must be provided in an assembler source file
and linked in with the project.
9.2.3 Clock
Specifies the relationship between the CPU clock cycles and the Kernel tick rate. For example if the
value of 1000 is used then 1000 CPU clock cycles is equivalent to one Kernel tick.
- 59 - F
9. Kernel LX51
For a 12MHz crystal, 1000 clock cycles is 83.333us. Therefore one Kernel tick is 83.333us.
The lower the value the faster the system will run, however if the value is too low then the Kernel will
spend all its time switching tasks, and not allow any tasks to execute.
9.2.4 Dividers
Each task is associated with a group. Each group of tasks execute at a specific speed that is a division
of the Kernel ticks.
• The Group 1 divider is the number of Kernel ticks in a Group 1 tick.
• The Group 2 divider is the number of Group 1 ticks in a Group 2 tick.
• The Group 3 divider is the number of Group 2 ticks in a Group 3 tick.
For example, if a Kernel tick is 83.333us , the Group 1 divider is 10, the Group 2 divider 100 and the
Group 3 divider 1000, then:
• Group 1 tick = 10 x Kernel tick = 833.333us
• Group 2 tick = 100 x Group 1 tick = 83.333ms
• Group 3 tick = 1000 x Group 2 tick = 83.333s
Therefore if a task in Group 3 waits for 5 ticks, it is waiting for 5 x 83.333s = 416.667s, which is about 6
minutes and 57 seconds.
On the other hand, if a task in Group 1 waits for 5 ticks, it is waiting for 5 x 833.333us = 4.167ms.
Separating tasks into groups allows the Kernel and the system to perform more efficiently and removes
the need for counters to be used inside rapidly executing tasks simply to measure a relatively long
period of time.
- 60 -
LX51 10. Initialization, buffers and stacks
The Linker provides various options to configure aspects of the memory usage. For example the Linker
can initialize internal RAM, allocate a specific amount of memory for printf and sprintf to operate
with, allow you to specify the size of the external stack, and initialize UART 0 to use a particular baud
rate. This chapter describes those options.
The value entered is passed to the Linker using the RSI directive.
Note: Initializing internal RAM is a very good idea. It improves the chances that an uninitialized pointer or
variable will point to or have the value zero, which is usually a safer value for a variable or pointer to
have.
If the value is changed from the default then Ride7 generates a special input object file containing the
public symbol SIZEBUFPRINTF. The symbol is set to the value entered for the buffer size. The object
file is linked with the other object files to enable the printf and sprintf library code to use the
symbol.
- 61 - F
10. Initialization, buffers and stacks LX51
The maximum size of the external stack is 256 bytes, however the size may be reduced. For example
if a device features 256 bytes of on-chip XDATA memory then 128 bytes could be used for the stack
and 128 bytes for variable storage.
Ride7 provides an easy way to set the size of the external stack, by entering the stack size into the
External stack size field.
If the value is changed from the default then Ride7 generates a special input object file containing the
public symbol XSTACKLEN. The symbol is set to the value entered for the stack size. The object file is
linked with the other object files to enable the external stack library code to use the symbol.
If the value is changed from the default then Ride7 generates a special input object file containing the
public symbol TIM1_INIT. The symbol is set to the value entered for the reload value. The object file
is linked with the other object files to enable the startup library code to use the symbol. To set the
option choose Options | Project, expand the LX51 portion of the tree and click on Startup.
Note: If it is not possible to generate the desired baud rate with an 8-bit reload value, or, if the Linker’s
initialization is not suitable for the application or microcontroller being used, then the peripherals can be
initialized as normal in the C source code, ignoring the Linker generated initialization code.
- 62 -
LX51 11. Appendix A. Directives reference
Directive Description
ABSOLUTECODEOFFS Offsets the address of all absolute code segments.
(ABSCODEOFFS)
BIT (BI) Specifies how relocatable bit-addressable segments should be located.
CODE (CO) Specifies how relocatable CODE segments should be located.
DATA (DT) Specifies how relocatable DATA segments should be located.
IDATA (ID) Specifies how relocatable IDATA segments should be located.
INPAGE (IP) Specifies segments that must fit into a 256-byte page.
MOVEABSCODE (MAC) Moves an absolute code segments to a new location.
PAGE (PA) Page aligns XDATA segments.
PDATA (PD) Specifies how relocatable PDATA segments should be located.
PRECEDE (PC) Specifies relocatable segments that must be located first.
STACK (ST) Specifies relocatable segments that must be located last.
STARTCODE (STCO) Specifies a start address for relocatable code segments.
XDATA (XD) Specifies how relocatable xdata segments should be located.
Directive Description
CODESIZE (CSIZE) Specifies the size of the CODE area.
MEMORYOFFSET (MO) Applies an offset to addresses used to access a segment.
NOFCTPTRMANAG (NOFPM) Function pointers are not automatically managed for the overlay process.
NOOVERLAY (NOOL) Do not overlay automatic variables.
OVERLAY (OL) Overlays automatic variables if possible and controls overlaying.
RAMSIZE (RS) Specifies the size of IDATA memory.
RAMSIZEINIT (RSI) Specifies the amount of IDATA to initialize.
SEGMENTOVERLAY (OS) Specifies segments for manual overlays.
-VN Instructs the Linker to assume a Von Neumann memory architecture.
XDATASIZE (XSIZE) Specifies the size of XDATA memory.
- 63 - F
11. Appendix A. Directives reference LX51
Directive Description
IXREF (IX) Instructs the Linker to generate a Cross-Reference file.
LINES (LI) Insert source code lines into symbol table.
MAP (MA) Include the Link map in the map file.
NOIXREF (NOIX) Instructs the Linker to not generate a Cross-Reference file.
NOLINES (NOLI) Omit source code lines from the symbol table.
NOMAP (NOMA) Omit the Link map from the map file.
NOPRINT (NOPR) Instructs the Linker to not generate a map file.
NOPUBLICS (NOPU) Omit public symbols from the symbol table.
NOSYMBOLS (NOSB) Omit symbols local to a module from the symbol table.
PRINT (PR) Instructs the Linker to generate a map file.
PUBLICS (PU) Inserts public symbols into the symbol table.
SYMBOLS (SB) Inserts symbols local to a module into the symbol table.
Directive Description
-C Turns on case sensitivity.
CASESENSITIVITY (CS) Turns on case sensitivity.
DEBUGLINES (DL) Includes source code line numbers in AOF file for debugging.
DEBUGPUBLICS (DP) Includes public symbols in AOF file for debugging.
DEBUGSYMBOLS (DS) Includes symbols local to modules in AOF file for debugging.
NAME (NA) Specifies the output module name.
NOCASESENSITIVITY (NOCS) Turns off case sensitivity.
NODEBUGLINES (NODL) Omit source code line numbers from the AOF file.
NODEBUGPUBLICS (NODP) Omit public symbols from the AOF file.
NODEBUGSYMBOLS (NODS) Omit symbols local to modules from the AOF file.
NODEFAULTLIBRARY (NLIB) Don’t automatically link in libraries when required.
POSTOPTI (POSTOPTI) Inserts information into the AOF file for post-linking optimization.
TO (TO) Specifies the filename of the AOF file.
- 64 -
LX51 11. Appendix A. Directives reference
Directive Description
BANK (BA) Specifies that a module should be located in a specific code bank
BANKAREA (BANKAREA) Specifies the start and end address range for code banks.
BANKMAX (BANKMAX) Specifies the upper boundary of a code bank.
BANKMIN (BANKMIN) Specifies the lower boundary of a code bank.
BANKMODE (BM) Selects code banking mode.
NOBRIDGE (NOBR) Disables generation of Bridges
Directive Description
FLASH (FLS) Specifies the start address of Flash memory and the object files to locate
in Flash.
FLASHBANKAREA Specifies the start and end address range which Flash banks occupy.
(FLSBANKAREA)
FLASHNAME (FLN) Specifies the file to store Flash information.
NOSTATVARROM Locates the initial values of static variables in Flash rather than ROM.
(NOSTATVARROM)
REFLASH (REFLS) Specifies the file containing Flash information in locked mode.
RESERVE (RES) Reserves memory for future enhancements.
STATVARROM Locates the initial values of static variables in ROM rather than Flash.
(STATVARROM)
Directive Description
AMAKE (AM) Ignored. Included for Keil compatibility.
GLOBAL (GLB) Allows directives to be used globally on all tools without generating errors.
NOAMAKE (NOAM) Ignored. Included for Keil compatibility.
- 65 - F
11. Appendix A. Directives reference LX51
- 66 -
LX51 11. Appendix A. Directives reference
- 67 - F
11. Appendix A. Directives reference LX51
- 68 -
LX51 11. Appendix A. Directives reference
11.15 -C
Syntax: -C
Description: Turns on Case Sensitivity in the Linker. ANSI C is case sensitive.
The variable FOO is not the same variable as the variable foo. However the OMF-51 file
format that is used for the object file is not case sensitive and FOO and foo will end up
referencing the same variable.
This directive ensures that the OMF-51 files are case sensitive. Therefore if your code
relies on case sensitivity you must use this directive.
This directive must appear before the list of input modules on the command line so the
Linker knows that it must parse all object files using case sensitivity.
Examples: -C
Default: The Linker is not case sensitive
Category: Object file
See Also: CASESENSITIVE, NOCASENSITIVE
- 69 - F
11. Appendix A. Directives reference LX51
- 70 -
LX51 11. Appendix A. Directives reference
- 71 - F
11. Appendix A. Directives reference LX51
- 72 -
LX51 11. Appendix A. Directives reference
- 73 - F
11. Appendix A. Directives reference LX51
- 74 -
LX51 11. Appendix A. Directives reference
- 75 - F
11. Appendix A. Directives reference LX51
- 76 -
LX51 11. Appendix A. Directives reference
- 77 - F
11. Appendix A. Directives reference LX51
- 78 -
LX51 11. Appendix A. Directives reference
- 79 - F
11. Appendix A. Directives reference LX51
- 80 -
LX51 11. Appendix A. Directives reference
- 81 - F
11. Appendix A. Directives reference LX51
- 82 -
LX51 11. Appendix A. Directives reference
- 83 - F
11. Appendix A. Directives reference LX51
- 84 -
LX51 11. Appendix A. Directives reference
- 85 - F
11. Appendix A. Directives reference LX51
11.67 TO (TO)
Syntax: TO(filename)
Description: Specifies the output filename of the generated absolute object file.
Examples: TO(FOO) Generates an absolute object file with the filename FOO
TO(FOO.AOF) Generates an absolute object file with the filename FOO.AOF
Default: TO(filename_based_on_first_module_name)For example if the first module
linked has the name FOO then the generated absolute object file will have the filename
FOO.
Category: Object file
See Also: FLASHNAME, NAME, PRINT
- 86 -
LX51 11. Appendix A. Directives reference
- 87 - F
12. Appendix B. Ride7 Linker options reference LX51
This Appendix provides an overview of the Linker options in Ride7. A screen shot of each subsection is
provided along with a description of each option in the subsection.
The Linker options may be accessed in Ride7 by choosing Options | Project Properties then
expanding the LX51 portion of the tree and selecting the subsections.
12.1.1 General
- 88 -
LX51 12. Appendix B. Ride7 Linker options reference
12.1.2 Memory
Code starting address Start address for CODE segments. Note that it CODE (address)
does not specify a start address for the reset
vector or interrupt vectors.
Xdata starting address Start address for the external RAM (XDATA) XDATA (address)
segments.
Idata starting address Start address of the indirect internal RAM IDATA (address)
(IDATA) segments.
Data starting address Start address of the direct internal RAM DATA (address)
(DATA) segments. Note that it does not affect
the location of the register banks.
Bit starting address Start address of the internal bit-addressable BDATA (address)
area (BDATA).
Absolute code address Offset to apply to absolute CODE segments. ABSCODEOFFS (offset)
- 89 - F
12. Appendix B. Ride7 Linker options reference LX51
12.1.4 Startup
Note: You should not specify a directive that will already be specified by selection or non-selection of a
linker option in one of the sections previously described.
- 90 -
LX51 13. Appendix C. Warning messages
Warning Description
WARNING 1: UNRESOLVED EXTERNAL SYMBOL
Cause: The Linker is unable to find the declaration of a symbol. Usually a variable is
declared as extern in one source file but the user forgets to actually declare the
variable in one of the source files, or the extern keyword is included by mistake in a
variable declaration.
Resolution:The Linker will display the symbol name, which is usually a variable or
function name and the object file or module that the symbol is referenced in.
Ensure the variable or symbol is declared somewhere in the project or remove the
erroneous extern keyword.
WARNING 2: REFERENCE MADE TO UNRESOLVED EXTERNAL
Cause: The Linker is unable to find the declaration of a symbol. Usually a variable is
declared as extern in one source file but the user forgets to actually declare the
variable in one of the source files, or the extern keyword is included by mistake in a
variable declaration.
This is similar to warning 1, however it indicates that the variable or function that
cannot be resolved is actually used in the project. There is the potential for the code to
behave in an undefined manner.
Resolution: The Linker will display the symbol name, which is usually a variable or
function name and the object file or module that the symbol is referenced in.
Ensure the variable or symbol is declared somewhere in the project or remove the
erroneous extern keyword.
WARNING 3: ASSIGNED ADDRESS NOT COMPATIBLE WITH ALIGNMENT
Cause: An attempt has been made to locate a segment at an address that conflicts
with the segment alignment. For example if a segment is Page aligned and an attempt
is made to locate the segment at 0101H then the warning will be generated at 0101H is
not a page aligned address.
Resolution: The warning message will indicate the segment in question. Modify the
address the segment is being located at so it is compatible with the alignment. The
Linker provides optimum performance and allows the greatest flexibility if segments
are only aligned when absolutely necessary.
WARNING 4: CODE SPACE MEMORY OVERLAP
Cause: The Linker has determined that some memory locations would be occupied by
more than one segment. The generated executable code will fail if an attempt is made
to execute one of the functions involved or read the constant data involved.
This is commonly caused by a clash in the starting locations of relocatable segments
that have been located using the CODE directive and/or absolutely located constant
data and/or absolute CODE segments (such as an interrupt vector).
- 91 - F
13. Appendix C. Warning messages LX51
Warning Description
Resolution: The Warning message indicates the memory location where the overlap
occurred. Check the Link map in the map file to determine which segments are
overlapping. Refer to section 4.3.Segment Naming Conventions to work out which
parts of the project are overlapped and change one of the addresses specified. Also
double-check the use of the CODE directive to ensure all segments are located at the
correct locations. One or more of the segments may have to be located elsewhere
depending on the project.
WARNING 5: XDATA SPACE MEMORY OVERLAP
Cause: The Linker has determined that some memory locations would be occupied by
more than one segment. The generated executable code will fail if an attempt is made
to the data involved.
This is commonly caused by a clash in the starting locations of relocatable segments
that have been located using the XDATA directive and/or absolutely located XDATA
data.
Resolution: The Warning message indicates the memory location where the overlap
occurred. Check the Link map in the map file to determine which segments are
overlapping. Refer to section 4.3.Segment Naming Conventions to work out which
parts of the project are overlapped and change one of the addresses specified. Also
double-check the use of the XDATA directive to ensure all segments are located at the
correct locations. One or more of the segments may have to be located elsewhere
depending on the project.
WARNING 6: DATA SPACE MEMORY OVERLAP
Cause: The Linker has determined that some memory locations would be occupied by
more than one segment. The generated executable code will fail if an attempt is made
to the data involved.
This is commonly caused by a clash in the starting locations of relocatable segments
that have been located using the DATA directive and/or absolutely located DATA data
and/or the register banks.
Resolution: The Warning message indicates the memory location where the overlap
occurred. Check the Link map in the map file to determine which segments are
overlapping. Refer to section 4.3.Segment Naming Conventions to work out which
parts of the project are overlapped and change one of the addresses specified. Also
double-check the use of the DATA directive to ensure all segments are located at the
correct locations. One or more of the segments may have to be located elsewhere
depending on the project.
WARNING 7: MODULE NAME NOT UNIQUE
Cause: Each source file generates an input module, whose name is derived from the
source file name. For example FOO.C generates a module called FOO. If a project
includes two modules with the same name then this warning is generated.
This situation can arise if a project contains a C source file and an assembler source
file with the same file name (excluding the extension), for example FOO.C and
FOO.A51. Also, although less likely, if a project contains a source file whose name just
happens to match a library module.
Resolution: The Warning message will indicate the module name that is not unique.
Rename the source file that generated the module and rebuild.
WARNING 11: EXTERNAL STACK LENGTH TOO LARGE, 256 ASSUMED
- 92 -
LX51 13. Appendix C. Warning messages
Warning Description
Cause: A size greater than 256 bytes has been specified for the external stack, and the
Linker has altered the size of the external stack to the maximum size of 256 bytes.
Resolution: Ensure that in the Linker options in Ride7 the external stack size is 256
bytes or less.
WARNING 12: UNKNOWN RECORD TYPE, RECORD IGNORED
Cause: The relocatable object files contain records as a method to store information.
Different types of information are stored in different records. This warning indicates
that the object file contained a record that the Linker did not recognize, and has
therefore ignored the record. This could result in non-functional code.
Resolution: Ensure that the Linker is attempting to link the correct object files,
generated by the Raisonance tools.
Try deleting all the .obj object files and recompiling/reassembling to ensure new object
files are generated.
Also try copying the source files and Project files only to a new directory and rebuilding.
WARNING 14: MULTIPLE CALL TO SEGMENT
This warning is a result of an internal error when performing the overlaying of
automatic variables. Please contact Raisonance for assistance if you see this error.
WARNING 16: UNCALLED SEGMENT: IGNORED FOR OVERLAY PROCESS
Cause: An executable CODE segment containing automatic variables is not called
from anywhere in the application. Therefore the automatic variables cannot and have
not been overlaid with the automatic variables of other functions, which may reduce
RAM usage.
Resolution: Refer to t section 4.3.Segment Naming Conventions to find out which
function is not being called. If a function call has been omitted then add it to the source
code.
However, if the function is not supposed to be called then this warning can be treated
as informational, warning you that not calling the function is resulting in potentially
more RAM being used than is necessary. If the function is a debug function then
surround it with conditional compilation so it is only included when debugging is
required and it will therefore be called from somewhere.
WARNING 18: CONTROL DIRECTIVE IGNORED
Cause: The compiler or assembler POSTOPTI directive is being used indicating the
linker should use the Code Compressor, however the current license does not allow
the Code Compressor to execute.
Resolution: Remove the directive or contact Raisonance to upgrade your tools to
include the Code Compressor.
WARNING 21: EMPTY RELOCATABLE SEGMENT
This warning is the result of an internal error in the assembler or compiler.
- 93 - F
14. Appendix D. Error messages LX51
Error Description
ERROR 100: UNRESOLVED EXTERNAL
Cause: The Linker is unable to find the declaration of a symbol. Usually a variable is declared
as extern in one source file but the user forgets to actually declare the variable in one of the
source files, or the extern keyword is included by mistake in a variable declaration.
Resolution: The Linker will display the symbol name, which is usually a variable or function
name and the object file or module that the symbol is referenced in.
Ensure the variable or symbol is declared somewhere in the project or remove the erroneous
extern keyword.
ERROR 101: SEGMENT COMBINATION ERROR
Cause: Partial segment with different attributes has been found. The attributes concern memory
class index or relocation type. For example:
main.a51:
?MYSEG SEGMENT CODE INBLOCK
main2.a51:
?MYSEG SEGMENT CODE
Resolution: The error message indicates which symbol has the problem. The symbol name
matches the segment name, so it is easy to check all segment declarations to ensure they are
identical.
ERROR 102: EXTERNAL ATTRIBUTES MISMATCH
Cause: A variable is declared as an extern in more than one module, however the memory
spaces of the declarations do not match. For example:
main.c:
extern char idata x;
main2.c:
extern char xdata x;
Resolution: The error message indicates which symbol has the problem. The symbol name
matches the variable name, so it is easy to check all extern declarations of that variable to
ensure they are identical.
ERROR 103: EXTERNAL ATTRIBUTES DO NOT MATCH PUBLIC
Cause: A variable is declared as extern in a module, however the memory space in the
declaration does not match the memory space of the actual variable declaration. For example:
main.c:
char idata x;
main2.c:
extern char xdata x;
Resolution: The error message indicates which symbol has the problem. The symbol name
matches the variable name, so it is easy to check all extern declarations of that variable to
ensure they are identical to the actual declaration.
- 94 -
LX51 14. Appendix D. Error messages
Error Description
ERROR 104: MULTIPLE PUBLIC DEFINITIONS
Cause: A variable with external linkage has been declared in more than one module. Omitting
the ‘extern’ keyword from an extern declaration can cause this. For example:
main.c:
char idata x;
main2.c:
char idata x;
Resolution: The error message indicates which symbol has the problem. The symbol name
matches the variable name, so it is easy to check all declarations of that variable to ensure they
are correct.
ERROR 106: SEGMENT OVERFLOW
Cause: This error indicates that a segment cannot be fit inside the memory space, for example
a DATA segment that is bigger than 128 bytes or an XDATA segment that is bigger than 65536
bytes.
Resolution: The error message indicates which segment has the problem. The symbol name
matches the segment name, so it is easy to check all declarations of that segment.
ERROR 107: ADDRESS SPACE OVERFLOW
Cause: The segments for a particular memory space are too large to all fit into memory. For
example this error will be generated if the source code results in more than 64K of code, and
Code Banking is not being used.
Resolution: The error message indicates the memory space that has overflowed. Reduce the
requirements on that memory space by optimizing the source code or removing unused
sections.
For example if the XDATA memory space has overflowed, then there may be some data that
can be moved to CODE memory space and uses as constants or stored in a serial memory
device.
If the CODE memory space has overflowed then ensure the highest level of optimization is
being used. Try changing the optimization settings to favor size. Look for places in the source
code that can be optimized. Also consider using Code Banking as a possible last resort.
If the PDATA, IDATA or DATA memory space has overflowed then look to see which variables
may be moved to the other memory spaces. Remember that DATA is the fastest memory,
followed by IDATA, PDATA then XDATA. Less frequently accessed variables are more suitable
to be stored in slower memory. Also check to see if the device features on-chip XDATA that can
be used.
ERROR 108: SEGMENT IN LOCATING CONTROL CANNOT BE ALLOCATED
Cause: When using Code Banking whole modules are located into banks. However, if a module
contains one or more absolute segments then this error will be generated.
This error may also be generated if you try to relocate any segment that is absolute or already
relocated with directives such as DATA, IDATA, XDATA, CODE, INPAGE or PAGE.
Resolution: Ensure that any absolute variables inside source files that are located in a Code
Bank are placed in a separate source files of their own.
Double-check that no segments are located twice with two different directives, or no attempt is
being made to relocate an absolute segment using DATA, IDATA, XDATA, CODE, INPAGE or
PAGE.
- 95 - F
14. Appendix D. Error messages LX51
Error Description
ERROR 109: EMPTY RELOCATABLE SEGMENT
Cause: This error is generated as the result of an internal error in the assembler or compiler.
Resolution: Please contact Raisonance for assistance.
ERROR 110: CANNOT FIND SEGMENT
Cause: A directive specifies a segment that does not exist. Commonly this is caused by a typo
in a segment name.
Resolution: The error message indicates the segment that cannot be found. Compare its name
with the segments that do exist in the project. They are listed in the Link map in the map file.
Please refer to section 5.4.Link map for information on reading the Link map. Please refer to
section 4.3.Segment Naming Conventions for other information.
ERROR 111: SPECIFIED BIT ADDRESS NOT ON BYTE BOUNDARY
Cause: The Linker has attempted to relocate a bit of a byte into the bit-addressable space,
however the address selected for the byte was not in the bit-addressable space (20H – 2FH).
Resolution: Ensure there is enough space free in the bit-addressable space. If necessary use
bit-fields for less frequently accessed bits, locating them in DATA memory or IDATA memory.
ERROR 112: SEGMENT TYPE NOT LEGAL FOR COMMAND
Cause: This error occurs when a segment specified with a directive such as CODE, XDATA,
: DATA, etc has the wrong memory space for that directive. For example, attempting to relocate
a code segment using the XDATA directive will generate this error.
Resolution: The error message indicates which segment has the problem. Look to find out
which directives the segment is specified with and remove the segment name or correct the
mistake.
ERROR 113: ABSOLUTE SEGMENT RELOCATION NOT ALLOWED
Cause: This error occurs when the user wants to relocate an absolute segment. An absolute
segment, having a forced address cannot be relocated (its address cannot be changed).
Resolution: Either do not try to relocate the absolute segment, or do not specify this segment as
absolute.
ERROR 115: INPAGE SEGMENT IS GREATER THAN 256 BYTES
Cause:An attempt has been made to relocate a segment using the INPAGE directive, but the
segment size is greater than 256 bytes (the size of a page) and therefore cannot fit inside a
page.
Resolution: The error message indicates which segment has the problem.
Either do not specify the segment with the INPAGE directive, or move some of the variables in
the segment into another segment, which can also be located using the INPAGE directive.
ERROR 116: INBLOCK SEGMENT IS GREATER THAN 2048 BYTES
Cause: The linker tries to locate a segment with the INBLOCK attribute, however the segment
size is greater than 2048 bytes and therefore the code may not execute properly.
This error is generated because the INBLOCK segment makes use of AJMP and ACALL
instructions. Both these instructions only allow 10-bit addressing and therefore can only jump to
or call an address within 2k of the instruction’s address.
- 96 -
LX51 14. Appendix D. Error messages
Error Description
Resolution: The error message indicates which segment has the problem. If the segment was
written in assembler then split it up into smaller segments.
If the segment was generated by the compiler then using the segment naming conventions to
work out which function generated the segment. Split the function up into smaller segments.
ERROR 119: REFERENCE MADE TO ERRONEOUS SEGMENT
Cause: Bank switching relies on a library segment called ?BANK?SWITCH. If this special
segment cannot be found then this error is generated.
Resolution: Ensure the environment options are correctly set so that the Library path points to
the LIB folder in the Ride7 installation.
Try uninstalling and reinstalling the tools to a new folder.
ERROR 121: IMPROPER FIXUP
Cause: When the Linker attempted to resolve a relocatable address used in an ACALL, AJMP
or relative jump instruction (JB, JNB, JC, JNC, SJMP, etc) – called a fixup - the address was
found to be out of the address range allowed by the instruction. For example ACALL instructions
can only jump to a location within the same 2048 byte block.
Resolution: The error gives the absolute address of the instruction whose address fixup failed.
The following steps determine the exact location in your code that the problem occurs:
Look at the Link map in the map file to determine which segment the absolute address is inside
of. Referring to the segment naming conventions in you can determine which function contains
the problem.
Take away the absolute address from the start address of the segment to obtain an offset into
the segment of the problem. For example if the absolute address given by the error was 0015H
and the segment starts at 0013H, the offset is 0015H – 0013H = 0002H.
Open the compiler listing file for the source file that contains the function and locate the
assembly listing for that function.
The first value on each assembler line is the offset into the function. For example the following
might be found for an offset of 0002H:
SOURCE LINE # 13
0002 1100 R ACALL foo ;
The instruction on the line is the one whose address fixup failed. In the example above the start
of the function foo must be more than 2048 bytes away from the ACALL instruction.
If the microcontroller you are using supports LCALL and LJMP instructions then switch from the
Tiny memory model to the Small memory model. If the problem occurs with a relative jump
instruction then reduce the size of the function by splitting it into smaller functions.
ERROR 122: CANNOT FIND MODULE
Cause: An attempt is being made to link with a module that cannot be found. A missing library
object file for example or an incorrectly entered command line could cause this.
Resolution: Ensure that all object files specified exist. Try copying the source files and Project
file to an empty directory and rebuilding.
If a library module is missing then try reinstalling the tools and rebuilding.
ERROR 124: RESERVED
This error is reserved for future use.
ERROR 125: RESERVED
- 97 - F
14. Appendix D. Error messages LX51
Error Description
This error is reserved for future use.
ERROR 128: NOBRIDGE OPTION USED WITHOUT CODE BANKING
Cause: The NOBR directive has been used without any other Code Banking directive.
Resolution: Either remove the NOBR directive or insert the necessary code banking directives
into the command line. If using Ride7 then check the option to use Code Banking.
ERROR 129: CANNOT FIND FUNCTION
Cause: A function specified using the OVERLAY directive could not be found in the project
Resolution: The error message indicates which function cannot be found. Check the Link map
in the map file to see which functions are present in the project and modify the OVERLAY
directive accordingly.
ERROR 130: CODE SPACE OVERLAP
Cause: The Linker has determined that some memory locations would be occupied by more
than one segment. The generated executable code will fail if an attempt is made to execute one
of the functions involved or read the constant data involved. This is commonly caused by a
clash in the starting locations of relocatable segments that have been located using the CODE
directive and/or absolutely located constant data and/or absolute code segments (such as an
interrupt vector).
Resolution: The Warning message indicates the memory location where the overlap occurred.
Check the Link map in the map file to determine which segments are overlapping. Refer to the
segment naming conventions to work out which parts of the project are overlapped and change
one of the addresses specified. Also double-check the use of the CODE directive to ensure all
segments are located at the correct locations. One or more of the segments may have to be
located elsewhere depending on the project.
ERROR 132: FIXUP OUTSIDE OF THE CODE SEGMENT LIMITS
Cause: This error is generated by an internal error of the compiler or assembler and means that
a symbol is referred to which is outside of the current code segment.
Resolution: Contact Raisonance for assistance.
ERROR 133: CANNOT FIND SYMBOL
Cause: This error occurs when using Flash mode. A symbol that was previously defined as
being in the ROM section was not found during the build.
Resolution: Once the ROM part is locked it must not change. Unlock the ROM part and rebuild
the project.
ERROR 134: SYMBOL ALREADY RELOCATED
Cause: This error occurs when a new build of the Flash section relocates a symbol located in
the ROM section, while using Flash mode.
Resolution: The error message indicates which symbol is being relocated. Ensure that variables
that are located in the ROM section once locked are not included in the Flash section.
ERROR 135: BANK SWITCHING IS NOT COMPATIBLE WITH CODE COMPRESSOR
Cause: This error occurs when using Bank Switching mode if the option Generate Post-
optimizing Information is checked in the Options|Target|Properties menu
- 98 -
LX51 14. Appendix D. Error messages
Error Description
Resolution: Use either Bank Switching mode or Code Compressor option.
ERROR 136: FLASH IS NOT COMPATIBLE WITH CODE COMPRESSOR
Cause: This error occurs when using Flash mode if the option Generate Post-optimizing
Information is checked in the Options|Target|Properties menu.
Resolution: Use either Flash mode or Code Compressor option.
- 99 - F
15. Appendix E. Fatal error messages LX51
Error Description
FATAL 201: INVALID COMMAND LINE SYNTAX
Cause: The Linker has been invoked from the command line, however the command was
incorrectly specified.
Resolution: The error message will indicate where the error occurred on the command line.
Refer to the directives reference in this manual and the command line syntax to located the
mistake and correct it.
FATAL 202: INVALID COMMAND LINE: TOKEN TOO LONG
Cause: The Linker has been invoked from the command line, however the command line was
longer than the maximum allowed by DOS.
Resolution: Use a Command file. A Command file is a plain text file that contains all the
command line arguments for the Linker. The arguments may be split into multiple lines if an
ampersand is placed at the end of each line.
Example command line: LX51 main.obj,main2.obj TO(main.aof)
Place command line arguments in a text file:
myproject.cmd:
Main.obj, main2.obj &
TO(main.aof)
Then invoke using the Command file: LX51 @myproject.cmd
- 100 -
LX51 15. Appendix E. Fatal error messages
Error Description
Cause: This error is generated if an invalid module is specified using the BANK or FLASH
directives.
Resolution: The error indicates the invalid module. Ensure that all modules specified exist and
were generated by the Raisonance tools. Try deleting all object file and rebuilding the project.
Try copying the source files and Project file to an empty directory and rebuilding the project.
FATAL 211: CODE BANKING SEGMENT MISSING OR INVALID
Cause: Bank Switching requires the use of a special library segment named ?BANK?SWITCH.
If the special segment cannot be found then this error is generated.
Resolution: Ensure the environment options are correctly set so that the Library path points to
the LIB folder in the Ride7 installation. Try uninstalling and reinstalling the tools to a new folder.
FATAL 214: INPUT PHASE ERROR
Cause: The Linker reads object files more than once while linking. This error indicates that for
some reason the object file has changed between passes.
Resolution: This error usually indicates an internal error in the Linker. Please contact
Raisonance for assistance.
FATAL 216: INSUFFICIENT MEMORY
Cause: The Linker ran out of memory while linking a project.
Resolution: Close some applications and try again to link the project. Press Ctrl-Alt-Delete and
check to make sure there are no unnecessary hidden tasks running.
FATAL 218: NOT AN OBJECT FILE
Cause: An attempt has been made to link a file that is not a valid object file or library file.
Resolution: Check to ensure that the Linker is linking the desired object files and library files. If
they are all correct, then delete the object file/library file and recompile/reassemble the source
file to generate new object files/library files. Try copying the source files and Project file to an
empty directory and rebuilding, to ensure no other files are being included by mistake.
FATAL 219: NOT AN 8051 OBJECT FILE
Cause: An attempt has been made to link a file that is not a valid 8051 object file or library file
Resolution: Check to ensure that the Linker is linking the desired object files and library files. If
they are all correct, then delete the object file/library file and recompile/reassemble the source
file to generate new object files/library files.
Ensure the project is set up for an 8051, not a different microcontroller family.
Try copying the source files and Project file to an empty directory and rebuilding, to ensure no
other files are being included by mistake.
FATAL 220: INVALID INPUT MODULE
Cause: An attempt is being made to link with an invalid input module.
Resolution: Ensure that the Raisonance tools generated all the object files being linked. Try
deleting all object files and rebuilding the project. Try copying the source files and Project file to
an empty directory and rebuilding. If the error persists then an internal error in the compiler or
assembler may be causing this problem. Contact Raisonance for assistance.
FATAL 221: MODULE SPECIFIED MORE THAN ONCE
- 101 - F
15. Appendix E. Fatal error messages LX51
Error Description
Cause: An attempt was made to link the same module more than once. This can be caused by
accidentally specifying the same object file twice on the command line.
Resolution: The error will indicate the offending module/source file. Check the project to ensure
it is only linked once. If using the command line then either modify one copy of the filename or
remove it.
FATAL 222: SEGMENT SPECIFIED MORE THAN ONCE
Cause: This error is caused by the same segment name being used inside both library code
and the user’s application.
Resolution: The error message indicates the segment name causing the problem. If using the
compiler then refer to the segment naming conventions to determine which part of the project is
generating the segment. Either the source file or function name will have to be renamed (if
applicable). If the assembler is being used then rename the segment to something else.
FATAL 224: DUPLICATE KEY WORD
Cause: This error is generated when a directive that may only be specified once is specified
more than once. For example: LX51 test.obj TO(test.aof) TO(test.aof)
The error message will indicate the directive that is duplicated.
Resolution: Carefully check the Linker command line to find the duplicate directive specified in
the error message and remove it.
FATAL 226: SEGMENT ADDRESS INVALID FOR CONTROL
Cause: The address specified in a relocating directive is out of range. For example
CODE(0x10000) will generate this error.
Resolution: The error message indicates the directive with the invalid address. If using the
command line modify the directive to correct the problem. If using Ride7 locate the control that
uses the directive and modify the setting accordingly.
FATAL 227: PAGEWIDTH PARAMETER OUT OF RANGE
Obsolete error – depricated directive.
FATAL 228: RAMSIZE PARAMETER OUT OF RANGE
Cause: More than 256 bytes of internal RAM have been specified.
Resolution: Modify the option in Ride7 or the value specified on the command line using the
RAMSIZE directive, to ensure that 256 bytes or less of internal RAM is specified.
FATAL 235: FLASHBANKAREA/BANKAREA PARAMETER OUT OF RANGE
Cause: The start address specified using the FLASHBANKAREA or BANKAREA directive is
higher than the end address specified with the same directive.
Resolution: Double check all uses of the FLASHBANKAREA and BANKAREA directives and
their associated Ride7 options to ensure that the desired addresses are used.
FATAL 237: MAXIMUM OBJECT SIZE REACHED
Cause: The evaluation version of the tools are being used which have a limit on the amount of
code that may be generated, for example 4Kb. This error is generated when the limit is
reached.
Resolution: Upgrade to the full version of the tools which do not have a code size limit.
- 102 -
LX51 15. Appendix E. Fatal error messages
Error Description
FATAL 239: ILLEGAL USE OF KERNEL
Cause: Some versions of the tools do not include a license to use the Kernel. If this error
message is generated then an attempt has been made to use the Kernel in a version that does
not allow it to be used.
Resolution: Upgrade to a version that includes a license to use the Kernel.
FATAL 240: INTERNAL PROCESS ERROR
Cause: This error is generated as a result of an internal error during linking.
Resolution: Please contact Raisonance for assistance.
FATAL 243: LITE VERSION: MAXIMUM OBJECT SIZE REACHED
Cause: The Lite version of the tools are being used which have a limit on the amount of code
that may be generated, for example 32Kb. This error is generated when the limit is reached.
Resolution: Upgrade to the full version of the tools which do not have a code size limit.
FATAL 245: UNKNOWN FIXUP
Cause: This error is generated by a relocatable address in the object file that cannot be
resolved, and is the result of an internal error.
Resolution: Please contact Raisonance for assistance.
FATAL 246: UNABLE TO REMOVE PREVIOUS TARGET
Cause: This error is generated when the .AOF (or .AOX) file cannot be removed. This file may
be already used or is set as read only.
Resolution: Check that nobody already uses it or that is not set as read only.
- 103 - F
16. Conformity LX51
16. Conformity
Raisonance products are certified to comply with the European Union RoHS Directive (2002/95/EC)
which restricts the use of six hazardous chemicals in its products for the protection of human health
and the environment.
The restricted substances are as follows: lead, mercury, cadmium, hexavalent chromium,
polybrominated biphenyls (PBB), and polybrominated diphenyl ethers (PBDE).
Raisonance products are certified to comply with the European Union CE Directive.
In a domestic environment, the user is responsible for taking protective measures from possible radio
interference the products may cause.
Raisonance disposes of its electrical equipment according to the WEEE Directive (2002/96/EC).
Upon request, Raisonance can recycle customer’s redundant products.
For more information on conformity and recycling, please visit the Raisonance website
www.raisonance.com
- 104 -
LX51 17. Glossary
17. Glossary
Term Description
CodeCompressor Post link code optimization tool
I/O Input/Output
ICC In-Circuit Communication
Ride7 Raisonance Integrated Development Environment
RLink Hardware tool for in-circuit debugging and programming of a target microcontroller
mounted on an application board. Supports interface via JTAG, ICC and SWIM
protocols.
SWIM Serial Wire Interface module
- 105 - F
18. Index LX51
18. Index
Alphabetical Index
ABSOLUTECODEOFFS...................................42 NOBRIDGE (NOBR).........................................65
Access functions...............................................55 NOCASESENSITIVITY (NOCS)........................64
AMAKE (AM).....................................................65 NODEBUGLINES (NODL)................................64
BANK (BA)........................................................65 NODEBUGPUBLICS (NODP)...........................64
Bank switches...................................................55 NODEBUGSYMBOLS (NODS).........................64
BANKAREA (BANKAREA)................................65 NODEFAULTLIBRARY (NLIB)..........................64
BANKMAX (BANKMAX)....................................65 NOFCTPTRMANAG.........................................47
BANKMIN (BANKMIN)......................................65 NOFCTPTRMANAG (NOFPM).........................63
BANKMODE (BM).............................................65 NOIXREF (NOIX)..............................................64
Baud rate...........................................................62 NOLINES (NOLI)...............................................64
BIT (BI)..............................................................63 NOMAP (NOMA)...............................................64
Bridges..............................................................54 NOOVERLAY (NOOL)......................................63
CASESENSITIVITY (CS)..................................64 NOPRINT (NOPR)............................................64
CE...................................................................104 NOPUBLICS (NOPU)........................................64
CODE (CO).......................................................63 NOSTATVARROM (NOSTATVARROM)..........65
CODESIZE (CSIZE)..........................................63 NOSYMBOLS (NOSB)......................................64
Compliance.....................................................104 Optimum memory usage...................................55
Conformity.......................................................104 Optimum performance......................................55
DATA (DT)........................................................63 OVERLAY.........................................................47
DEBUGLINES (DL)...........................................64 OVERLAY (OL).................................................63
DEBUGPUBLICS (DP)......................................64 PAGE (PA)........................................................63
DEBUGSYMBOLS (DS)....................................64 PDATA (PD)......................................................63
Directive..........................................................104 POSTOPTI (POSTOPTI)..................................64
FCC.................................................................104 PRECEDE (PC).................................................63
FLASH (FLS).....................................................65 PRINT (PR).......................................................64
FLASHBANKAREA (FLSBANKAREA)..............65 PUBLICS (PU)...................................................64
FLASHNAME (FLN)..........................................65 Raisonance ....................................................104
GLOBAL (GLB).................................................65 RAMSIZE (RS)..................................................63
IDATA (ID).........................................................63 RAMSIZEINIT (RSI)..........................................63
Increase code memory to 4Mb..........................49 Reduce RAM requirement.................................43
Initialize internal RAM........................................61 REFLASH (REFLS)...........................................65
INPAGE (IP)......................................................63 RESERVE (RES)..............................................65
ISR execution time............................................55 ROHS..............................................................104
IXREF (IX).........................................................64 SEGMENTOVERLAY (OS)...............................63
L51_BANK.A51.................................................52 STACK (ST)......................................................63
Large Look-up tables.........................................55 STARTCODE (STCO).......................................63
Lead................................................................104 STATVARROM (STATVARROM).....................65
LINES (LI).........................................................64 SYMBOLS (SB).................................................64
MAP (MA)..........................................................64 TO (TO).............................................................64
MEMORYOFFSET (MO)...................................63 Web site..............................................................8
MOVEABSCODE..............................................42 WEEE.............................................................104
MOVEABSCODE (MAC)...................................63 XDATA (XD)......................................................63
NAME................................................................20 XDATASIZE (XSIZE).........................................63
NAME (NA).......................................................64 -C64
NOAMAKE (NOAM)..........................................65 -VN....................................................................63
NOBRIDGE.......................................................55 ?BANK?SWITCH..............................................54
- 106 -
LX51 19. History
19. History
Date Modification
09 Mar 2010 Initial version for Ride7.
Disclaimer
Information in this document is subject to change without notice and does not represent a commitment
on the part of the manufacturer. The software described in this document is provided under license and
may only be used or copied in accordance with the terms of the agreement. It is illegal to copy the
software onto any medium, except as specifically allowed in the license or non disclosure agreement.
No part of this manual may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, recording, or information storage and retrieval systems, for any
purpose other than the purchaser’s personal use, without prior written permission.
Every effort has been made to ensure the accuracy of this manual and to give appropriate credit to
persons, companies and trademarks referenced herein.
This manual exists both in paper and electronic form (pdf).
Please check the printed version against the .pdf installed on the computer in the installation directory,
for the most up-to-date version.
The examples of code used in this document are for illustration purposes only and accuracy is not
guaranteed. Please check the code before use.
Copyright © Raisonance 1987-2010 All rights reserved
- 107 - F