3 pc relative mode, Pc relative mode -40 – Freescale Semiconductor StarCore SC140 User Manual

Page 72

Advertising
background image

2-40

SC140 DSP Core Reference Manual

Address Generation Unit

active SP register are unchanged. The type of arithmetic used is always linear. An example is:
move.w #$ffff,(sp–$3e)

. The encoded displacement is 31,the maximum value of five bits,

and the actual displacement is 62 ($3e), since the access width is two.

SP Word Displacement, (SP + xxxx)—The operand address is the sum of the contents of the active
stack pointer (SP) and an immediate displacement. The displacement is a signed 15-bit word that
requires a second instruction word. It is sign-extended to 32 bits and added to the active stack pointer
(NSP in Normal mode, ESP in Exception mode) to obtain the operand address. Thus, the
displacement can range from [-16,384] to [+16,383] bytes, [-8192] to [+8191] words, [-4096] to
[+4095] long words, or [-2048] to [+2047] two long words according to the access width. The
contents of the active SP register are unchanged. The type of arithmetic used is always linear. An
example is: move.l

(sp+$2000),d2.e

. Here, the positive value $2000 is added to the active

stack pointer before the memory access.

2.3.3.3 PC Relative Mode

The PC relative address mode is used to calculate the program destination of change-of-flow instructions
such as branches (BRA). In the PC relative addressing mode, the instruction encoding contains a signed
displacement operand. The operand address is obtained by left-shifting (multiplying by two) the
displacement and adding the result to the value of the program counter (PC). The operand is left-shifted
because the addresses of the program instructions are word-aligned, and memory addressing is in units of
bytes. The arithmetic used is always linear. For example,

bra _label2

. Assume that PC=$0010 and that

_label2 is at location $0020. The encoded displacement will be ($0020 – $0010)/2 = $0008.

The number of bits occupied by the displacement in the instruction differs with the different kinds of PC
relative instructions. In all cases, the displacement is first sign-extended to 32 bits, then multiplied by two,
and added to the PC to obtain the operand address.

In the one-word conditional branch instructions, the displacement occupies 8 bits of the instruction word
and can range from [-256] to [254] words. In the one-word unconditional branch instructions, the
displacement occupies 10 bits of the instruction word and can range from [-1024] to [1022] words. In the
two-word branch instructions, the displacement occupies 20 bits and can range from [-1,048,576] to
[1,048,574] words. In the DOSETUP instruction, the displacement occupies 16 bits of the instruction. The
displacement for the start address (SA) can range from [-65,536] to [65,534] words.

Advertising