User manual
ST Assembler-Linker ST assembler
Doc ID 11392 Rev 4 29/89
cod parameter, output file control
The last field of a SEGMENT directive controls where the linker places the code for a given
class. When introducing a class, if this field is not specified, the code for this class is sent to
the normal, default.COD file by the linker. If the [cod] file is given a number between 0 and
9 then all code generated under the class being introduced will be sent to a different '.COD'
file by the linker.
If the linker produces a file called 'prog.cod', for example, then all code produced under
classes with no [cod] field will go into that file, as normal.
If one class is introduced with a [cod] field of 1, though, then all code produced under that
class is sent instead to a file prog_1.cod. The code produced under the other classes is
sent on as usual to prog.cod.
Using this scheme, you can do bank switching schemes quickly and directly, even when
multiple EPROMs share the same addressing space. Simply allocate each EPROM class of
its own, and introduce each class with a different [cod] field. This will result in the linker
collating EPROM's contents into a different .COD file for you to OBSEND independently.
For example:
segment byte at:8000-BFFF 'eprom1' 1
segment byte at:8000-BFFF 'eprom2' 2
Copying code
It sometimes happens that you need to copy a block of code from EPROM to RAM. This
presents some difficulties because all labels in that piece of code must have the RAM
addresses, otherwise any absolute address references in the code will point back to the
EPROM copy.
In this case, it helps to specify a class for execution, and use a different class for storage,
as in the following example:
segment byte at: 0 'code'
segment byte at: 8000 'ram'
segment 'ram>code'
label1:nop
The code starting from label1 will be stored in the code class as usual, but all the labels in
that special segment will be given addresses in the ram class, and memory will also be
reserved in the ram class for the contents of the special segment.