This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

using the "_at_" keyword in some case mess up variable storage

Hi,
it seems that using "_at_" keyword with extern variables does not work well.
The code below shows what I wish to share with you guys.

/////////////////////////////////////////////
sample.c:

xdata volatile unsigned char xdata_var_bad _at_ 16;
xdata volatile unsigned char xdata_var_ok _at_ 16;

void test( void )
{
  xdata_var_bad = 0;
  xdata_var_ok = 0;

}
/////////////////////////////////////////////




/////////////////////////////////////////////
sample.h:

extern xdata volatile unsigned char xdata_var_bad _at_ (16);
extern xdata volatile unsigned char xdata_var_ok;
/////////////////////////////////////////////




/////////////////////////////////////////////
main.c:

#include "sample.h"

void main(void)
{
	xdata_var_bad =0;
	// disassembly for above assignment is:
	//		MOV	 DPTR,#0x0000
	//     		MOV      A,#0
	//		MOVX     @DPTR,A

	xdata_var_ok =0;
	// disassembly for above assignment is:
	//		MOV	 DPTR,#0x0010
	//     		MOV      A,#0
	//		MOVX     @DPTR,A
}
/////////////////////////////////////////////


Any commment ?
Boris

0