mcdir=c:\\microc
# Note: 'm=2' option defines the compact memory model for mcc51
casm.asm : casm.c
$mcdir\\mcp $. $@.tmp -l l=$mcdir
$mcdir\\mcc51 $@.tmp $@.asm -l -c m=2
# Note: An external index file must be specified for slink using the 'i' option
prog.hex : casm.asm myasm.asm
$mcdir\\slink $. $@.asm l=$mcdir\\lib51 i=compact.lib
$mcdir\\asm51 $@ -fs
The following routines are utilized by the C compiler to manage internal and external memory pointers.
1
// casm.c
// C file showing parameter passing and interface between C and assembly
main()
{
//local variables are allocated on the external SRAM stack, referenced by ?stack
int ivar1, ivar2, ivar3, ivar4;
char cvar1, cvar2;
ivar1 = 5;
ivar2 = 8;
cvar1 = 1;
cvar2 = 2;
2
*myasm.asm
*Assembly file showing parameter passing between C and assembly.
3
The following figure shows the contents of external SRAM (?stack) after program execution completes.
DF90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DFA0 00 00 00 00 01 05 00 08 00 0E 00 0D 00 01 02 00
DFB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
External SRAM [after main() completes; Note: no variables actually exist at that time]