I have developed a small Single Board computer, with a few customizations..
I am well versed in Assembly programming for 8052, but not for C. I have written driver functions for the devices on the board in assembly and this "BIOS" will be burned in the on-chip 20KB (89c55) eeprom as a simple monitor program. Upon startup, it will initialize some variables, a custom protocol stack and then jump to user program rom (at 8000h) address.
I want to write user codes in C, but in SMALL and / or COMPACT modes, since C uses the internal data ram for stack and other variables, this might clash with the BIOS variables that are at fixed internal-ram addresses.
Secondly, the BIOS program will initialize stack to reside in the extra 128-bytes ram (80h and above) while it is not certain where C will put the stack to start at.
Can anyone guide me as to how this situation can be avoided ?
WEll, thanks guys.
Arthur.. the development environment and cross-compiler are selected to be Keil C..so that not an issue. Maybe i wasnt able to explain in detail. I am relatively new to C programming for 8052 environment, and specifically to Keil, so yes i might have missed a few key points in Keil's documentation, and thanks for the tips / pointer.
Tsuneo..thanks for the descriptive message, i guess i can handle the rest from here. Incase something goes wrong or i cant understand.. i'll let u guys know so u can fill in. Thanks a lot.
One more thing though..the custom protocol stack wont be called by the User C code. The BIOS codes specific to the protocol handling will recieve a valid packet from the serial lines, and only if the packet is intended for a particular control card (address matching with address stored in serial EEPROM 24cxxx series) then a DATA RECIEVED flag wud be set which the user code can uery by wrapper functions and then read the packet data.
Likewise, if the user C code has to reply with a packet..it would send teh packet data to the BIOS functions by wrapper functions, which would actually do the transmitting.
I will make available the BIOS routines and protocol stack once it is finalized, for any one's review or usage online.
Thanks again.
"the custom protocol stack wont be called by the User C code... it would send teh packet data to the BIOS functions by wrapper functions, which would actually do the transmitting."
Do you mean that some interrupt summons up your BIOS from the user's C code, and just the variables are exposed to the user's code as the common resource?
Then provide a library, in which the common variables are declared on absolute address using _at_ keyword.
If you don't like to expose some variables, but ensure the address, declare it as static variables in the library file.
For example,
volatile unsigned char idata bios_flag _at_ 0x80; // exposed to users static unsigned char idata reserved_area[15] _at_ 0x81; // not exposed
Absolute Variable Location http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm
In this way, you can ensure the BIOS variables without any linker directive, like IDATA.
Tsuneo