ARM Technical Support Knowledge Articles

OVERLAYING DATA WITH ORG EMITS NO WARNINGS

Applies to: A51 Macro Assembler

Answer


Information in this article applies to:


SYMPTOM

Creating an assembler program using ORG statements to overlay data generates no warnings. For example, the following program:

org 8000h
d1:  db 1, 2, 3, 4, 5, 6, 7, 8
org 8002h
d2:  db 1, 2, 3, 4, 5, 6, 7, 8
end

overlays data in d1 with data from d2.

CAUSE

The Keil tools use multiple ORG statements within a segment to overlay variables. For example:

void c_func (void)
{
while (P1)
  {
  int var1, var2, var3;

  /*** do something ***/
  }

while (P2)
  {
  int var4, var5, var6;

  /*** do something ***/
  }
}

In this C function var1, var2, and var3 are only in scope in the while (P1) loop. Outside that loop these variables are no longer valid. The memory they use may be reused by other similarly scoped variables (like var4, var5, and var6 in the while (P2) loop).

To do that, the compiler generates a segment for the local variables of c_func that is similar to the following:

       RSEG  ?DT?c_func?MAIN
?c_func?BYTE:
       var1?040:   DS   2
       var2?041:   DS   2
       var3?042:   DS   2
ORG 0000h
       var4?043:   DS   2
       var5?044:   DS   2
       var6?045:   DS   2

Using the ORG statement this way allows the compiler and assembler to re-use variable space.

RESOLUTION

There is currently no planned change to this functionality.

Article last edited on: 2004-05-01 20:27:36

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