| |||||
Technical Support Support Resources
Product Information | A51: OVERLAYING DATA WITH ORG EMITS NO WARNINGSInformation in this article applies to:
SYMPTOMCreating 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. CAUSEThe 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. RESOLUTIONThere is currently no planned change to this functionality. Last Reviewed: Saturday, May 01, 2004 | ||||
| |||||