I am developing an application using MC68HC908GZ60 and CodeWarrior 6.3.1 in pure relocatable assembly. I have two tables to read. One has 128 of 16-bit entries, the other has 256 of 8-bit entries. I want to locate them on a $00 address boundary (ex: $2100, $2200) and read entries using index register with either
mov x+,target_addr
or
ldhx table_addr
lda <8-bit ADC input>
tax
lda ,x
'ALIGN 256' directive does not align at all and this mistake is clearly seen in
Project.map as table start addresses are $214C $1E39.
Why compiler is ignoring my ALIGN directive? What should I do to really ALIGN
my tables?
code snippets:
SINETABLE SECTION
ALIGN $100
sinetable: dc.w 2146, 2244, 2341, 2438, 2533, 2628, 2721, 2813
dc.w 2903, 2990, 3076, 3159, 3239, 3316, 3391, 3462
...........
EXPTABLE SECTION
ALIGN 256
exptable: dc.b 0, 0, 0, 0, 0, 0, 0, 1
dc.b 1, 1, 1, 1, 1, 1, 1, 1
............
from Project.map :
- PROCEDURES:
sinetable 1E39 10 16 2 MOTOR_Code
VAR00001 1E49 10 16 0 MOTOR_Code
VAR00002 1E59 10 16 0 MOTOR_Code
......
exptable 214C 8 8 1 EXPTABLE
VAR00001 2154 8 8 0 EXPTABLE
Out of the assembler manual:
*************************************************************************************** ALIGN - Align Location Counter
Syntax
ALIGN <n>
Synonym
None
Description
This directive forces the next instruction to a boundary that is a multiple of <n>, relative to the start of the section. The value of <n> must be a positive number between 1 and 32767. The ALIGN directive can force alignment to any size. The filling bytes inserted for alignment purpose are initialized with `\0'.
***************************************************************************************
I highlighted the part that ALIGN is relative to the start of the section, say it is not aligning relative to the final address.
As the two ALIGN's are both at section offset 0, the alignment is trivially satisfied and nothing gets inserted.
You may want to look into the linker manual, the prm file supports a syntax to align all the section start addresses.
If you just have 2 arrays of known sizes it might also be simpler to allocate them into a specific placement in the prm file instead of allocating them together with the rest of the code.
Daniel