Keil Logo

A51: Variable Alignments and EVEN Directive


Information in this article applies to:

  • A51 All Versions
  • Ax51 All Versions
  • A251 All Versions

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 relocatable 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 relocatable 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

  • Refer to ORG in the Ax51 User's Guide.

Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.