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

#DEFINE and EXTRN NUMBER are incompatible ???

Dear friends,

Plz help me in solving this bad problem:

PROBLEM DESCRIPTION:

I have a number defined in C and I DONT want to alocate memory in 8051 for this number :

#define myNumber 0x1234

All is well, when i work with myNumber in C for example:

HiByte=myNumber/256;

will translate as expected:
MOV HiByte,#012H ;
No memory alocated for myNumber and stil, C compiler is capable to make calculus based on it.

Happy with that, now i try tu use myNumber (remember defined in C) in ASM.
And that is the problem: I'm unnable to found a method to see myNumberin ASM.

Shortly:
Seems to me that A51 compiler is unable to see a numerical constant declared in C51 with #define directive (but mybe i missing something out, and that's why I ask for your expertize, Dear friends)

An example follows:

//---------file main.c----------------

//I wish to see this number both in C and ASM
//PLZ NOTE: I dont want to reserve memory for myNumber
//i only wish to use it's High Byte in a data memory location

#define myNumber 0x1234

//function defined in ASM which use myNumber
extern  unsigned char GetHiByte(void);

//reserve memory location
unsigned char HiByte;

void main (void)
{
	HiByte=myNumber/256;//all is well in C
	HiByte=GetHiByte();//dont work in ASM, myNumber is not seen
			   //and is initialized to zero
}

;-------file func.a51-----------------

?PR?GetHiByte?FUNC? segment code

	EXTRN NUMBER (myNumber)

	public GetHiByte

rseg ?PR?GetHiByte?FUNC?

	using 0
GetHiByte:

	mov r7,#HIGH(myNumber)
	ret

end

Linker errors:
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: MYNUMBER
MODULE: func.obj (FUNC)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: MYNUMBER
MODULE: func.obj (FUNC)
ADDRESS: 0016H

0