Motorola dsp assembler Reference Manual



Yüklə 4,8 Kb.
Pdf görüntüsü
səhifə19/91
tarix08.10.2017
ölçüsü4,8 Kb.
#3546
1   ...   15   16   17   18   19   20   21   22   ...   91

Software Project Management
Sections And Data Hiding
4-4
DSP ASSEMBLER REFERENCE MANUAL
MOTOROLA
4.3.2
  Sections and Macros
The division of a program into sections controls not only labels and symbols, but also mac-
ros and DEFINE directive symbols.  Macros defined within a section are private to that
section and are distinct from macros defined in other sections even if they have the same
macro name.  Macros defined outside of sections are considered global and may be used
within any section.  Similarly, DEFINE directive symbols defined within a section are pri-
vate to that section and DEFINE directive symbols defined outside of any section are glo-
bally applied.  There are no directives that correspond to XDEF for macros or DEFINE
symbols, therefore macros and DEFINE symbols defined in a section can never be ac-
cessed globally.  If global accessibility is desired, the macros and DEFINE symbols should
be defined outside of any section.  Here is an example:
DEFINE
DEFVAL
'1'
SECTION
SECT1
DEFINE
DEFVAL
'2'
MOVE
#DEFVAL,R0
ENDSEC
MOVE
#DEFVAL,R1
The second definition of DEFVAL is visible only inside SECT1, so the value moved to R0
will be 2.  However, the second move instruction is outside the scope of SECT1 and will
therefore use the initial definition of DEFVAL.  This means that the value 1 will be moved
to R1.
4.3.3
  Nested and Fragmented Sections
Sections can be nested to any level. When the Assembler encounters a nested section,
the current section is stacked and the new section is used. When the ENDSEC directive
of the nested section is encountered, the Assembler restores the old section and uses it.
The  ENDSEC directive always applies to the most recent SECTION directive. Nesting
sections provides a measure of scoping for symbol names, in that symbols defined within
a given section are visible to other sections nested within it. For example, if section B is
nested inside section A, then a symbol defined in section A can be used in section B with-
out XDEFing in section A or XREFing in section B. This scoping behavior can be turned
off and on with the NONS and NS options respectively (see the OPT directive, Chapter 6).
Sections may also be split into separate parts.  That is,  can be used mul-
tiple times with SECTION and ENDSEC directive pairs.  If this occurs, then these separate
(but identically named) sections can access each others symbols freely without the use of
the  XREF and XDEF directives.  If the XDEF and XREF directives are used within one
section, they apply to all sections with the same section name.  The reuse of the section
name is allowed to permit the program source to be arranged in an arbitrary manner (for
example, all statements that reserve X space storage locations grouped together), but re-
tain the privacy of the symbols for each section.


Software Project Management
Sections And Relocation
MOTOROLA
DSP ASSEMBLER REFERENCE MANUAL
4-5
4.4
  SECTIONS AND RELOCATION
When the Assembler operates in relative mode (the default), sections act as the basic
grouping for relocation of code and data blocks.  For every section defined in the source
a set of location counters is allocated for each DSP memory space.  These counters are
used to maintain offsets of data and instructions relative to the beginning of the section.
At link time sections can be relocated to an absolute address, loaded in a particular order,
or linked contiguously as specified by the programmer.  Sections which are split into parts
or among files are logically recombined so that each section can be relocated as a unit.
Sections may be relocatable or absolute.  In the Assembler absolute mode (command line
-A option) all sections are considered absolute.  In relative mode, all sections are initially
relocatable.  However, a section or a part of a section may be made absolute either im-
plicitly by using the ORG directive, or explicitly through use of the MODE directive.
If the Assembler encounters an ORG directive with an absolute runtime address specifi-
cation it switches to absolute mode and begins generating absolute addresses within the
enclosing section.  Note that the mode change is effective only if  the Assembler was start-
ed in relative mode; if the -A command line option is used the Assembler always gener-
ates absolute addresses.  The Assembler continues to generate absolute code until an
ENDSEC directive is encountered, or the mode is explicitly changed via the MODE direc-
tive.
The MODE directive allows for arbitrary switching between absolute and relocatable code
generation:
MODE

The MODE directive may be issued at any time in the assembly source to alter the set of
location counters used for section addressing.  Code generated while in absolute mode
will be placed in memory at the location determined during assembly.  Relocatable code
and data within a section are combined at link time, even if absolute blocks are inter-


Software Project Management
Address Assignment
4-6
DSP ASSEMBLER REFERENCE MANUAL
MOTOROLA
spersed among relocatable blocks.  The MODE directive has no effect when the com-
mand line -A option is active.  The following is an example:
SECTION
EXAMPLE
; relocatable section
; code/data generated here is relocatable
MODE
ABSOLUTE
; code/data generated here is absolute; it will be
; placed in memory at the location specified during
; assembly
MODE
REL
; back to relocatable; code/data generated here
; will be combined with the previous relocatable block,
; as long as memory space and mappings are compatible
ORG
P:$200
; code/data generated here will be absolute
; until ENDSEC directive is found
ENDSEC
More information on the ORG and MODE directives can be found in Address Assignment
and under the individual directive descriptions in Chapter 6.
If the STATIC qualifier follows the  in the SECTION directive, then all code
and data defined in the section until the next ENDSEC directive are relocated in terms of
the immediately enclosing section. The effect with respect to relocation is as if all code
and data in the section were defined within the parent section. This is useful when a sec-
tion needs data hiding, but independent relocation is not required.
4.5
  ADDRESS ASSIGNMENT
The Motorola DSP Assembler can support absolute address assignment at assembly
time or generation of relocatable program addresses which are resolved during the linking
phase.  The ORG directive is used to specify memory space changes, mappings to phys-
ical memory, and absolute address assignment.
Various memory layouts require special handling for data generation or location counter
updating. In the case of L memory, two words of code or data are produced for each in-


Yüklə 4,8 Kb.

Dostları ilə paylaş:
1   ...   15   16   17   18   19   20   21   22   ...   91




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə