cross referencing variables
Page 1 of 1

Author:  wentworth [ Mon May 07, 2012 8:34 am ]
Post subject:  cross referencing variables


I am developing some code using the IDE68K developement environment, my project has, other than the usual cstart.asm, 2 code modules a 68000 assembly .a68 file and a C source .c file.

within the Assembly there is a varuable defined and used

section data
xdef __exitflag
__exitflag: dcb 1,0 * define exit flag 1 byte, set to 0

And my assembly references the __exitflag as you would expect.

But I also want to reference this byte in memory from the C program and for it to be referenced by its name and not coded to be in a fixed memory location. So my C code is :

extern unsigned char __exitflag;

within the definitions and then later in the C code :

while (__exitflag == 0)

which obviously waits for the __exitflag to be non zero.

But when I build the project I always get an "Undefined symbol" error when assembling the combined project .src file.

Any ideas where I am going wrong? I suspect the problem is in the assembly define and I've tried a few variations but still undefined....

Author:  clive [ Mon May 07, 2012 2:01 pm ]
Post subject: 

I think the C compiler adds a '_' on to all procedures and variables. Also consider marking it as volatile if it is touched outside the scope of the routine, ie via interrupt.

extern volatile unsigned char _exitflag;

// ...

while (_exitflag == 0)

Review the listing file from IDE68K to see what it is doing.

Author:  wentworth [ Mon May 07, 2012 8:06 pm ]
Post subject: 


Thanks very much; the extra "_" was the issue.

And yes it was an interupt routine that was setting the __exitflag.

Thanks again

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group