Motorola dsp assembler Reference Manual



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

MOTOROLA
DSP ASSEMBLER REFERENCE MANUAL
4-1
Chapter 4
SOFTWARE PROJECT MANAGEMENT
4.1
  INTRODUCTION
The Motorola DSP Assemblers provide several directives designed to assist in the devel-
opment of large software projects. Complex software projects often are divided into small-
er program units. These subprograms may be written by a team of programmers in
parallel, or they may be programs written for a previous development effort that are going
to be reused. The Assembler provides directives to encapsulate program units and permit
the free use of symbol names within subprograms without regard to symbol names used
in other programs. These encapsulated program units are called sections. Sections are
also the basis for relocating blocks of code and data, so that concerns about memory
placement are postponed until after the assembly process.
4.2
  SECTIONS
A section is bounded by a SECTION directive and an ENDSEC directive.  For example:
SECTION   [GLOBAL | STATIC | LOCAL]
.
.
Section source statements
.
.
ENDSEC
All symbols that are defined within a section have the  associated with
them. This serves to protect them from like-named symbols elsewhere in the program. By
default, a symbol defined inside any given section is private to that section unless the
GLOBAL or LOCAL qualifiers accompany the SECTION directive. More information on
the GLOBAL and LOCAL qualifiers can be found in Sections And Data Hiding, below.
Any code or data inside a section is considered an indivisible block with respect to relo-
cation. Code or data associated with a section is independently relocatable within the
memory space to which it is bound, unless the STATIC qualifier follows the SECTION di-
rective on the instruction line. More information on the STATIC qualifier is available in
Sections And Relocation, below.


Software Project Management
Sections And Data Hiding
4-2
DSP ASSEMBLER REFERENCE MANUAL
MOTOROLA
4.3
  SECTIONS AND DATA HIDING
Symbols within a section are generally distinct from other symbols used elsewhere in the
source program, even if the symbol name is the same.  This is true as long as the section
name associated with each symbol is unique, the symbol is not declared public (XDEF or
GLOBAL), and the GLOBAL or LOCAL qualifiers are not used in the section declaration
(see below).  Symbols that are defined outside of a section are considered global symbols
and have no explicit section name associated with them.  Global symbols may be refer-
enced freely from inside or outside of any section, as long as the global symbol name does
not conflict with another symbol by the same name in a given section.  Consider the fol-
lowing example:
SYM1
EQU
1
SYM2
EQU
2
SECTION
EXAMPLE
SYM1
EQU
3
MOVE
#SYM1,R0
MOVE
#SYM2,R1
ENDSEC
MOVE
#SYM1,R2
SYM1 and SYM2 are global symbols, initially defined outside of any section.  Then in sec-
tion EXAMPLE another instance of SYM1 is defined with a different value.  Because
SYM1 was redefined inside the section, the value moved to R0 will be 3.  Since SYM2 is
a global symbol the value moved to R1 will be 2.  The last move to R2 is outside of any
section and thus the global instance of SYM1 is used; the value moved to R2 is 1.
4.3.1
  Sections and Symbols
Symbols may be shared among sections through use of the XDEF and XREF directives.
The  XDEF directive instructs the Assembler  that certain symbol definitions that occur
within the current section are to be accessible by other sections:
XDEF
,,...,
The XREF directive instructs the Assembler that all references to  within the cur-
rent section are references to a symbol that was declared public within another section
with the XDEF directive:
XREF
,,...,


Software Project Management
Sections And Data Hiding
MOTOROLA
DSP ASSEMBLER REFERENCE MANUAL
4-3
XDEFed symbols by default are recognized only in other sections which XREF them.
They can be made fully global (recognizable by sections which do not XREF them) by use
of the XR option (see the OPT directive, Chapter 6). Alternatively the GLOBAL directive
(see Chapter 6) may be used within a section to make the named symbols visible outside
of the section. Both the XDEF and XREF directives must be used before the symbols to
which they refer are defined or used in the section. Here is another example:
SYM1
EQU
1
SECTION
SECT1
XDEF
SYM2
SYM1
EQU
2
SYM2
EQU
3
ENDSEC
SECTION
SECT2
XREF
SYM2
MOVE
#SYM1,R0
MOVE
#SYM2,R1
ENDSEC
MOVE
#SYM2,R2
SYM1 is first defined outside of any section.  Then in section SECT1 SYM2 is declared
public with an XDEF directive.  SYM1 is also defined locally to section SECT1.  In section
SECT2 SYM2 is declared external via the XREF directive, followed by a move of SYM1
to R0.  Since SYM1 was defined locally to section SECT1, the Assembler uses the global
value and moves a 1 to R0.  Because SYM2 was declared external in section SECT1 the
value moved to R1 is 3.  If SYM2 had not been XREFed in section SECT2 the value
moved to R1 would have been unknown at this point.  In the last instruction it is not known
what value will be moved to R2 since SYM2 was not defined outside of any section or was
not declared GLOBAL within a section.
If the GLOBAL qualifier follows the
 in the SECTION directive, then all
symbols defined in the section until the next ENDSEC directive are considered global.
The effect is as if every symbol in the section were declared with the GLOBAL directive.
This is useful when a section needs to be independently relocatable, but data hiding is not
required.
If the LOCAL qualifier follows the
 in the SECTION directive, then all sym-
bols defined in the section until the next ENDSEC directive are visible to the immediately
enclosing section.  The effect is as if every symbol in the section were defined within the
parent section.  This is useful when a section needs to be independently relocatable, but
data hiding within an enclosing section is not required.
Symbols that are defined with the SET directive can be made visible with XDEF only in
absolute mode, and the section name associated with the symbol will be the section name
of the section where the symbol was first defined. This will be true even if the symbol value
is changed in another section.


Yüklə 4,8 Kb.

Dostları ilə paylaş:
1   ...   14   15   16   17   18   19   20   21   ...   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ə