Académique Documents
Professionnel Documents
Culture Documents
Chapter 3
Addressing Modes
C54x
C55x
y = x1 + x0 + x2 init[3] x[3]
Procedure
Allocate sections (code, constants, vars)
Setup addressing modes
Add the values (x1 + x0 + x2)
Store the result (y)
How do we allocate the proper sections?
SIEE, Slide 7 Copyrigh
Writing relocatable code
The programmer should not have to give the
exact addresses:
where to read the code in program memory,
where to read the data in data memory.
The assembler allows to use symbolic addresses.
The assembler and the linker work with COFF
files:
COFF = Common Object File Format.
In COFF files, specialized sections are used for code,
variables or constants.
The programmer specifies in a command file for the
linker where the different sections should be
allocated in the memory of the system.
Named
sections, name .sect .usect
given by user
Unnamed
sections, .text .data .bss
default name
System Diagram
Short value
3, 5, 8, 9 bits constant Example:
1 word, 1 cycle LD #6, DP
To initialize short Load DP with the value 6.
length registers or bit
fields:
DP, ASM …
SIEE, Slide 16
Not always available Copyrigh
Example: MMR (Memory Mapped Registers)
and Immediate Addressing
.sect ”init" STM (STore to Memory-mapped
tbl .int 1,2,3 register) stores an immediate
value to the specified MMR or
x .usect "vars",3 Scratch address.
y .usect "result",1
.sect “code”
start: STM #tbl,AR1
STM #x,AR2
#tbl is the 16-bit address of the
first element of the array tbl.
0000
h MMR = Memory Mapped Registers
MMRs
0060
h Scratch Scratch memory
007F
128 0080
Page 1 128 words
256 0100
Page 2 128 words
512 Pages
DP register 9-bit DP
SP relative, CPL = 1
SP Register 16-bit Stack Pointer
+ 7-bit dma
Page 3 to 510
x .usect "vars",3
y .usect "result",1
.sect “code”
start: STM #tbl,AR1
STM #x,AR2
ARi
End_address =
xxxxxxxxxxx11111
x .usect "vars",3
y .usect "result",1
.sect “code”
start: STM #tbl,AR1
STM #x,AR2 Initialization of AR1 and AR2.
LD *AR1+,A
Copy the values from table in DROM
STL A,*AR2+ ;... to RAM (via A). Indirect addressing
allows sequential access to data.
LD #x,DP
System Diagram
LD @x+1,A
ADD @x,A
DROM RAM
ADD @x+2,A
tbl[3] x[3]
LD @x+1,A
ADD @x,A
ADD @x+2,A
0000h
MMRs Tip: use the .mmregs directive
to allow MMR names to be
interpreted as addresses
0060h
Scratch
007Fh
+ 7-bit @x
= 23-bit address
= 23-bit address
.dp x
indir: AMOV #x,XAR0
AMOV #tbl,XAR6
Offset into Buffer = + ARn/CDP
Buffer Length = BKzz[15:0]
.dp x
indir: AMOV #x,XAR0
AMOV #tbl,XAR6
BSET/BCLR bit_name