processFuncArgs(currFunc,0);
/* set the stack pointer */
- stackPtr = -1 - (IS_ISR(name->etype)) - (IS_RENT(name->etype) | options.stackAuto);
- xstackPtr= -1;
+ /* PENDING: check this for the mcs51 */
+ stackPtr = -port->stack.direction * port->stack.call_overhead;
+ if (IS_ISR(name->etype))
+ stackPtr -= port->stack.direction * port->stack.isr_overhead;
+ if (IS_RENT(name->etype) || options.stackAuto)
+ stackPtr -= port->stack.direction * port->stack.reent_overhead;
+
+ xstackPtr = -port->stack.direction * port->stack.call_overhead;
fetype = getSpec(name->type); /* get the specifier for the function */
/* if this is a reentrant function then */
char bitaddr, /* bit addressable space*/
char codemap, /* this is code space */
unsigned sloc, /* starting location */
- char *name, /* 2 character name */
+ const char *name, /* 2 character name */
char dbName
)
{
/* choose which stack 2 use */
/* use xternal stack */
if ( options.useXstack ) {
+ /* PENDING: stack direction support */
SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = xstack ;
SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack =
xstackPtr - getSize(lval->type);
}
else { /* use internal stack */
SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = istack ;
- SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack =
- stackPtr - ( SPEC_BANK(currFunc->etype) ? 1 : 0) -
- getSize(lval->type) -
- (IS_ISR(currFunc->etype) ? 4 : 0);
- stackPtr -= getSize (lval->type);
+ if (port->stack.direction > 0) {
+ SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack =
+ stackPtr - ( SPEC_BANK(currFunc->etype) ? port->stack.bank_overhead : 0) -
+ getSize(lval->type) -
+ (IS_ISR(currFunc->etype) ? port->stack.isr_overhead : 0);
+ stackPtr -= getSize (lval->type);
+ }
+ else {
+ /* This looks like the wrong order but it turns out OK... */
+ /* PENDING: isr, bank overhead, ... */
+ SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack = stackPtr;
+ stackPtr += getSize (lval->type);
+ }
}
allocIntoSeg(lval->sym);
}
sym->onStack = 1;
if ( options.useXstack ) {
+ /* PENDING: stack direction for xstack */
SPEC_OCLS(sym->etype) = xstack ;
SPEC_STAK(sym->etype) = sym->stack = (xstackPtr + 1);
xstackPtr += getSize (sym->type) ;
}
else {
SPEC_OCLS(sym->etype) = istack ;
- SPEC_STAK(sym->etype) = sym->stack = ( stackPtr + 1);
- stackPtr += getSize (sym->type) ;
+ if (port->stack.direction > 0) {
+ SPEC_STAK(sym->etype) = sym->stack = ( stackPtr + 1);
+ stackPtr += getSize (sym->type) ;
+ }
+ else {
+ stackPtr -= getSize (sym->type);
+ SPEC_STAK(sym->etype) = sym->stack = stackPtr;
+ }
}
allocIntoSeg(sym);
return ;
int size = getSize(sym->type);
/* nothing to do with parameters so continue */
if ((sym->_isparm && !IS_REGPARM(sym->etype)))
- continue ;
+ continue ;
if ( IS_AGGREGATE(sym->type)) {
+ if (port->stack.direction > 0) {
SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1);
sPtr += size;
- continue ;
+ }
+ else {
+ sPtr -= size;
+ SPEC_STAK(sym->etype) = sym->stack = sPtr;
+ }
+ continue;
}
/* if allocation not required then subtract
continue ;
}
- SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1);
- sPtr += size ;
+ if (port->stack.direction > 0) {
+ SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1);
+ sPtr += size ;
+ }
+ else {
+ sPtr -= size ;
+ SPEC_STAK(sym->etype) = sym->stack = sPtr;
+ }
}
/* do the same for the external stack */
int size = getSize(sym->type);
/* nothing to do with parameters so continue */
if ((sym->_isparm && !IS_REGPARM(sym->etype)))
- continue ;
+ continue ;
if (IS_AGGREGATE(sym->type)) {
- SPEC_STAK(sym->etype) = sym->stack = ( xsPtr + 1);
- xsPtr += size ;
- continue ;
+ SPEC_STAK(sym->etype) = sym->stack = ( xsPtr + 1);
+ xsPtr += size ;
+ continue ;
}
/* if allocation not required then subtract
struct value ;
typedef struct memmap{
unsigned char pageno;/* page no for this variable */
- char *sname; /* character prefix for map */
+ const char *sname; /* character prefix for map */
char dbName ; /* debugger address space name */
int slbl ; /* label counter for space */
unsigned sloc ; /* starting location */
#define IN_CODESPACE(map) (map && map->codesp)
/* forward decls for functions */
-memmap *allocMap (char,char,char,char,char,char,unsigned,char *,char );
+memmap *allocMap (char,char,char,char,char,char,unsigned, const char *,char );
void initMem ( );
void allocGlobal (struct symbol * );
void allocLocal (struct symbol * );