ARM Technical Support Knowledge Articles

LOCATING VARIABLES IN ASSEMBLY

Applies to: A51 Macro Assembler

Answer

QUESTION

How do I locate variables at specific addresses in 8051 assembly?

ANSWER

There are a number of ways to locate symbols at specific addresses in assembly. Two are presented here.

One way is to use the BIT, CODE, DATA, IDATA, and XDATA assembler directives to specify the variable and the address. For example:

DATA_THING  DATA  20h

DATA_THING is replaced by 20h when you assemble your program.

The problem with this solution is that the assembler does not reserve any memory for DATA_THING and it may get overwritten by another part of your program.

Another method is to create absolute segments using the BSEG, CSEG, DSEG, ISEG, and XSEG directives. For example:

DSEG AT 40h
DATA_THING   DS 4

When you use DATA_THING, the assembler uses the address 40h. And, since we have reserved 4 bytes, the linker "knows" that the memory from 40h to 43h is already used and will avoid putting other data there.

These are just 2 of the ways you can place variables at specific locations.

SEE ALSO

Refer to the Assembler User's Guide for more information and details.

Article last edited on: 2004-05-08 16:41:59

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