Motorola DSP56305 User Manual Page 45

  • Download
  • Add to my manuals
  • Print
  • Page
    / 112
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 44
3-16 Optimizing DSP56300/DSP56600 Applications MOTOROLA
Program Control
PC Relative Instructions
There are two main advantages for using PC relative addressing
over absolute addressing:
1. Code Relocation—Code written with PC relative code could
be relocated, reused or imported to different program
addresses without the need to update the program labels.
2. Code Compactness—Most address references are generally
to locations not many memory words away in the program.
Therefore, the PC displacement will usually be a small
number, that may fit in the address field of a 1-word opcode.
Absolute addressing generally will not fit, and requires a
second word to specify it.
Compare the following 2 examples:
;first example: using absolute addressing
cmp x0,a
jne _CONT
inc b
_CONT
rts
;second example: using PC relative addressing
cmp x0,a
bne <_CONT1
inc b
_CONT1
rts
After assembly, the labels _CONT and _CONT1 have definite
values. In the first example, if _CONT > 4095, then the Assembler
must use the 2-word opcode, placing the value of _CONT as the
second word. _CONT1, however, has the value of 2, therefore fitting
into the 1-word opcode version of the instruction Bcc (Branch on
Condition). Furthermore, the value of _CONT1 remains the same
regardless of the location of the code in the program space. The
Short Addressing mode force operator (“<” in the Bne argument)
Note: 1. The LRA opcode can only add a displacement to the PC. The Assembler
translates the absolute address to displacement from the Location Counter, so
the two modes (absolute address/ displacement register) are the same from the
machine’s point of view.
Table 3-5 Instructions with Program Memory Arguments
Function
Address
Argument
Mnemonic
The Address Argument
Encoded in the
opcode
(total 1 w)
2nd
word
Register Data
Memory
<ea>
Page view 44
1 2 ... 40 41 42 43 44 45 46 47 48 49 50 ... 111 112

Comments to this Manuals

No comments