You are on page 1of 47

Data addressing modes provide various ways to access operands to execute instructions and place results in the memory

or the registers.

In immediate addressing, the instruction syntax contains the specific value of the operand. Two types of values can be encoded in an instruction: Short immediate values can be 3, 5, 8, or 9 bits in length. Long immediate values are always 16 bits in length. Immediate values can be encoded in 1-word or 2word instructions. The 3-, 5-, 8-, or 9-bit values are encoded into 1word instructions; 16-bit values are encoded into 2word instructions.

The length of the immediate value encoded in an instruction depends on the type of instruction used.

The syntax for immediate addressing uses a number sign (#) immediately preceding the value or symbol to indicate that it is an immediate value. For example, to load accumulator A with the value 80 in hexadecimal, LD #80h, A RPT instruction: a long-immediate (#lk) value is encoded in instructions that use immediate addressing. The opcode of the instruction is encoded in the high half of the instruction, bits 015 of the high word of a 2-word encoding. The value of the constant is in the remaining instruction space.

Data-memory address (dmad) addressing: MVDK Smem, dmad, MVDM dmad, MMR, MVKD dmad, Smem MVMD MMR, dmad Program-memory address (pmad) addressing: FIRS Xmem, Ymem, pmad MACD Smem, pmad, src MACP Smem, pmad, src MVDP Smem, pmad MVPD pmad, Smem Port address (PA) addressing: PORTR PA, Smem PORTW Smem, PA *(lk) addressing is used with all instructions that support the use of a single data-memory (Smem) operand. Absolute addresses are always encoded with a length of 16 bits, so instructions that encode absolute addresses are always at least two words in length.

dmad Addressing Data-memory address (dmad) addressing uses a specific value to specify an address in data space. The syntax for dmad addressing uses a symbol or a number to specify an address in data space. For example, to copy the value contained at the address labeled SAMPLE in data space to the memory location in data space pointed to by AR5, one would write: MVKD SAMPLE, *AR5 In this example, the address referenced by SAMPLE is the dmad value.

pmad Addressing Program-memory address (pmad) addressing uses a specific value to specify an address in program space. The syntax for pmad addressing uses a symbol or a number to specify an address in program space. For example, to copy a word in the program memory location labeled TABLE to a data-memory location specified by AR7, one would write: MVPD TABLE, *AR7 In this example, the address referenced by TABLE is the pmad value.

PA Addressing Port address (PA) addressing uses a specific value to specify an external I/O port address. The syntax for PA addressing uses a symbol or a number to specify the port address. For example, to copy a value from the I/O port at port address FIFO to a data-memory location pointed to by AR5, one would write: PORTR FIFO, *AR5 In the example, FIFO refers to the port address.

*(lk) Addressing *(lk) addressing uses a specific value to specify an address in data space. The syntax for *(lk) addressing uses a symbol or a number to specify an address in data space. For example, to load accumulator A with the value contained in address BUFFER in data space, one would write: LD *(BUFFER),A The syntax for *(lk) addressing allows all instructions that use Smem addressing to access any location in data space without changing the DP or initializing an AR.

Accumulator Addressing: Accumulator addressing uses the value in the accumulator as an address. This addressing mode is used to address program memory as data. Two instructions allow to use the accumulator as an address: READA Smem, WRITA Smem READA transfers a word from a program-memory location specified by accumulator A to a datamemory location specified by the single datamemory (Smem) operand of the instruction. WRITA transfers a word from a data-memory location specified by the Smem operand of the instruction to a program-memory location specified by accumulator A.

Direct Addressing In direct addressing, the instruction contains the lower seven bits of the data memory address (dma). The 7-bit dma is an address offset that is combined with a base address, with the datapage pointer (DP), or with the stack pointer (SP) to form a 16-bit data-memory address. Using this form of addressing, you can access any of 128 locations in random order without changing the DP or the SP.

Either DP or SP can be combined with the dma offset to generate the actual address. The compiler mode bit (CPL), located in status register ST1, selects which method is used to generate the address: When CPL = 0, the dma field is concatenated with the 9-bit DP field to form the 16-bit data-memory address. When CPL = 1, the dma field is added (positive offset) to SP to form the 16-bit data-memory address. The syntax for direct addressing uses a symbol or a number to specify the offset value. For example, to add the contents of the memory location SAMPLE to accumulator B, provided that the correct base address is in DP (CPL = 0) or SP (CPL = 1), you would write: ADD SAMPLE, B The lower seven bits of the address of SAMPLE are stored in the instruction word.

In DP-referenced direct addressing, the 7-bit dma in the instruction register is concatenated with the 9-bit DP to form the address. DP-referenced direct addressing divides memory into 512 pages, because the DPs range is from 0 to 511 (29 1). Each page has 128 addressable locations, because the dma ranges from 0 to 127 (27 1). In other words, the DP points to one of 512 possible 128-word data-memory pages; the dma points to the specific location within that page. The only difference between an access to location 0 on page 1 and to location 0 on page 2 is the value of the DP. The DP is loaded by the LD instruction.

SP-Referenced Direct Addressing In SP-referenced direct addressing, the 7-bit dma in the instruction register is added as a positive offset to the SP to form the effective 16bit data-memory address. The SP points to any address in memory. The dma points to the specific location on the page, allowing you to access a contiguous 128-word (2^7 1) block in memory from any base address. SP can also add or remove items from the stack.

Indirect Addressing: In indirect addressing, any location in the 64Kword data space can be accessed using the 16bit address contained in an auxiliary register. The C54xDSP has eight 16-bit auxiliary registers (AR0AR7). Indirect addressing is used mainly when there is a need to step through sequential locations in memory in fixed-size steps.

When memory is addressed with indirect addressing, the auxiliary register and the address can be optionally modified by a decrement, an increment, an offset, or an index. Special modes offer circular and bit-reversed addressing. A circular buffer size register (BK) is used with circular addressing. The AR0 register is used for indexed and bitreversed addressing modes in addition to being used to point to memory as the other auxiliary registers do.

Indirect addressing is flexible enough not only to read or write a single 16-bit data operand from memory with one instruction, but also to access two data memory locations with one instruction. Accesses of two data-memory locations include reads of two independent memory locations, reads and writes of two consecutive memory locations, and a read of one memory location combined with a write to a memory location.

ARAU and Address-Generation Operation Two auxiliary register arithmetic units (ARAU0 and ARAU1) operate on the contents of the auxiliary registers. The ARAUs perform unsigned, 16-bit auxiliary register arithmetic operations. Some addresses can be obtained by premodifying the auxiliary register.

Memory-mapped register addressing is used to modify the memory-mapped registers without affecting either the current data-page pointer (DP) value or the current stack-pointer (SP) value. Because DP and SP do not need to be modified in this mode, the overhead for writing to a register is minimal. Memory-mapped register addressing works for both direct and indirect addressing.

Addresses are generated by: Forcing the nine most significant bits (MSBs) of data-memory address to 0, regardless of the current value of DP or SP when direct addressing is used Using the seven LSBs of the current auxiliary register value when indirect addressing is used If AR1 is used to point to a memory-mapped register in memory mapped register addressing mode and it contains a value of FF25h.

Then AR1 points to the timer period register (PRD), since the seven LSBs of AR1 are 25h and the address of the PRD is 0025h. After execution, the value remaining in AR1 is 0025h.

The system stack is used to automatically store the program counter during interrupts and subroutines. The stack is filled from the highest to the lowest memory address. The processor uses a 16-bit memory mapped register, the stack pointer (SP), to address the stack. SP always points to the last element stored onto the stack.

Four instructions access the stack using the stack addressing mode: PSHD pushes a data-memory value onto the stack. PSHM pushes a memory-mapped register onto the stack. POPD pops a data-memory value from the stack. POPM pops a memory-mapped register from the stack.

A push predecrements and a pop postincrements the address in the SP.

Other operations also affect the stack and the stack pointer. The stack is used during interrupts and subroutines to save and restore the PC contents. When a subroutine is called or an interrupt occurs, the return address is automatically saved in the stack using a push operation. When a subroutine returns, the return address is retrieved from the stack using a pop operation and loaded into the PC.

Circular Addressing: Many algorithms, such as convolution, correlation, and FIR filters, require the implementation of a circular buffer in memory. In these algorithms, a circular buffer is a sliding window containing the most recent data. As new data comes in, the buffer overwrites the oldest data. The key to the implementation of a circular buffer is the implementation of circular addressing.

The circular-buffer size register (BK) specifies the size of the circular buffer. A circular buffer of size R must start on a N-bit boundary (that is, the N LSBs of the base address of the circular buffer must be 0), where N is the smallest integer that satisfies 2N> R. The value R must be loaded into BK. For eg, a 31-word circular buffer must start at an address whose five LSBs are 0 (that is, XXXX XXXX XXX0 00002), and the value 31 must be loaded into BK.

A 32-word circular buffer must start at an address whose six LSBs are 0 (that is, XXXX XXXX XX00 00002), and the value 32 must be loaded into BK. The effective base address (EFB) of the circular buffer is determined by zeroing the N LSBs of a user-selected auxiliary register (ARx). The end of buffer address (EOB) of the circular buffer is determined by replacing the N LSBs of ARx with the N LSBs of BK.

The index of the circular buffer is simply the N LSBs of ARx and the step is the quantity being added to or subtracted from the auxiliary register. RULES: Place the first (lowest) address of the circular buffer on a 2N boundary where 2N is larger than the circular buffer size. Use a step less than or equal to the circular buffer size. The first time the circular queue is addressed, the auxiliary register must point to an element in the circular queue.

The algorithm for circular addressing is as follows: If 0 <= index + step<BK index = index + step Else if index + step >=BK index = index + step BK Else if index + step < 0 index = index + step + BK Circular addressing can be used for single datamemory or dual data-memory operands. When BK is zero, the circular modifier results in no circular address modification.

Bit-reversed addressing enhances execution speed and program memory for FFT algorithms that use a variety of radixes. In this addressing mode, AR0 specifies one half of the size of the FFT. The value contained in AR0 must be equal to 2N1, where N is an integer, and the FFT size is 2N. An auxiliary register points to the physical location of a data value.

When you add AR0 to the auxiliary register using bit-reversed addressing, the address is generated in a bit-reversed fashion, with the carry bit propagating from left to right, instead of the normal right to left.

Dual data-memory operand addressing is used for instructions that perform two reads or a single read and a parallel store (indicated by two vertical bars, ||) at the same time. These instructions are all one word long and operate in indirect addressing mode only. Two data-memory operands are represented by Xmem and Ymem: Xmem is a read operand with access through the D bus.

Ymem is used as a read operand in instructions with dual reads (accessed through the C bus) or as a write operand in instructions with a parallel store (accessed through the E bus). Because only two bits are available for selecting each auxiliary register in this mode, only four of the auxiliary registers can be used, AR2 AR5.

You might also like