I have an application, for an 8051 device, that accepts commands, acts on them, and provides a reply. I want to implement a command that will load code (for an new function) into a reserved section of Code memory so that the code will run when a different command jumps to it. I'm having trouble getting the standalone function, which needs to access data arrays and other functions in the main application, to link (BL51 linker) without warnings. My test function is:
void Cipher (unsigned char *in, unsigned char *out); extern unsigned char xdata Data_Bffer[]; extern unsigned char xdata PlainTxt[]; void User1(void) { PlainTxt[0] = 0x06; //ASCII "ACK" PlainTxt[1] = 0xAA; PlainTxt[2] = 0x55; PlainTxt[3] = 0xAA; PlainTxt[4] = 0x55; PlainTxt[5] = 0xAA; PlainTxt[6] = 0x55; PlainTxt[7] = 0xAA; PlainTxt[8] = 0x55; PlainTxt[9] = 0xAA; PlainTxt[10] = 0x55; PlainTxt[11] = 0xAA; PlainTxt[12] = 0x55; PlainTxt[13] = 0xAA; PlainTxt[14] = 0x55; PlainTxt[15] = 0xAA; Cipher(&PlainTxt[0], &Data_Bffer[0]); return; }
and the project also contains the following assembly code file:
$NOMOD51 PUBLIC Data_Bffer PUBLIC PlainTxt PUBLIC Cipher Data_Bffer EQU 0DE0h PlainTxt EQU 0FF0h Cipher EQU 2104h END
where the addresses for the data arrays and the function Cipher are taken from the .M51 file of the main application. I'm getting warnings like the following from the linker:
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL SYMBOL: _CIPHER MODULE: C:\Users\R\UserFunctions.obj (USERFUNCTIONS)>> *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL SYMBOL: ?_CIPHER?BYTE MODULE: C:\Users\R\UserFunctions.obj (USERFUNCTIONS)
My Assembler, Compiler, and Linker command lines are unaltered from the defaults (in the Silicon Labs IDE); e.g. linker command line is:
RS(256) PL(68) PW(78)
If I change "Cipher" to "_Cipher" in the Assembly file, then the first warning goes away. But I don't know what to do about "?_CIPHER?BYTE". Anyone tried something like this before and know the fix?
Changing the Cipher prototype to specify XDATA for the arguments and then using the NOOVERLAY directive eliminated the warnings I was receiving. Thanks.