* Improved the pop params code
[fw/sdcc] / src / z80 / gen.c
index 625ea1036ee262e97cf580c16fc94afb1c1bbb97..fef1897971e31b66912125bcaff8219dc16cabba 100644 (file)
@@ -1097,13 +1097,19 @@ static void emitCall (iCode *ic, bool ispcall)
     /* adjust the stack for parameters if required */
     if (IC_LEFT(ic)->parmBytes) {
        int i = IC_LEFT(ic)->parmBytes;
-       /* PENDING: do better */
-       while (i>1) {
-           emitcode("pop", "hl");
-           i-=2;
+       if (i>6) {
+           emitcode("ld", "hl,#%d", i);
+           emitcode("add", "hl,sp");
+           emitcode("ld", "sp,hl");
+       }
+       else {
+           while (i>1) {
+               emitcode("pop", "hl");
+               i-=2;
+           }
+           if (i) 
+               emitcode("inc", "sp");
        }
-       if (i) 
-           emitcode("inc", "sp");
     }
 
 }