some -xstack related stuff
[fw/sdcc] / src / mcs51 / gen.c
index b468463f063591aa51e55c198ee777c4cdb7b163..a960c041a885466b338f4ae27bdc34ed7829b1ed 100644 (file)
@@ -2106,6 +2106,17 @@ static void genFunction (iCode *ic)
     if (IS_RENT(sym->etype) || options.stackAuto) {
 
        if (options.useXstack) {
+               /* set up the PAGE for the xternal stack */
+               if (sym->args) {
+                       emitcode("push","dph");
+                       emitcode("push","acc");
+               }
+               emitcode("mov","dph,__page_no__");
+               emitcode("movx","a,@dptr");
+               if (sym->args) {
+                       emitcode("pop","acc");
+                       emitcode("pop","dph");
+               }               
            emitcode("mov","r0,%s",spname);
            emitcode("mov","a,_bp");
            emitcode("movx","@r0,a");