ARM Technical Support Knowledge Articles

VARIABLE ALIGNMENTS AND EVEN DIRECTIVE

Applies to: A51 Macro Assembler

Answer


Information in this article applies to:


QUESTION

I have purchased the A51 Macro Assembler and I need to control variable alignments. I know that the AX51 and A251 support the EVEN directive (and this would be exactly what I need) but I do not want to migrate to AX51.

I have tried to use the ORG statement, however I keep getting error message like:

ERROR #A14: BAD RELOCATABLE EXPRESSION

Is there a chance to control alignments in A51 using the ORG directive?

ANSWER

The simple form of the ORG statement can be used to control alignment in absolute segments. For example the following code will translate fine:

XSEG AT 2000H                    ; segment at xdata address 0x2000.
myvar1: DS 10

ORG      ($+15) AND 0FFF0H       ; 16-BYTE alignment for next variable
myvar2:  DS 3

ORG      ($+1)  AND 0FFFEH       ; EVEN (WORD) alignment for next variable
myvar3:         DS 2

However this code fails in relocateable segments due to the relative nature of the $ symbol which represents the address counter. But when you subtract the segment start address you can make it work in A51. So the following example works on relocateable segments too:

?XD?myseg segment xdata
      rseg ?XD?myseg
start:                           ; start label used to make the expression absolute
myvar1: DS 10

ORG      ($-start+15) AND 0FFF0H ; 16-BYTE alignment for next variable
myvar2:  DS 3

ORG      ($-start+1)  AND 0FFFEH ; EVEN (WORD) alignment for next variable
myvar3:  DS 2

It should be noted that the alignments are based on the segment start and are therefore relative to the segment start address. You may use the PAGE segment alignment type here that is supported by A51. Again, AX51 and A251 have a lot more possibilities.

MORE INFORMATION

Article last edited on: 2005-07-22 16:58:38

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential