+ /* if we are calling a not _naked function that is not using
+ the same register bank then we need to save the
+ destination registers on the stack */
+ if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) &&
+ (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) &&
+ !IFFUNC_ISISR (dtype))
+ {
+// saveRBank (FUNC_REGBANK (dtype), ic, TRUE);
+// restoreBank=TRUE;
+ swapBanks = TRUE;
+ // need caution message to user here
+ }
+
+ if (IS_LITERAL(etype))
+ {
+ /* if send set is not empty then assign */
+ if (_G.sendSet)
+ {
+ genSend(reverseSet(_G.sendSet));
+ _G.sendSet = NULL;
+ }
+
+ if (swapBanks)
+ {
+ emitcode ("mov", "psw,#0x%02x",
+ ((FUNC_REGBANK(dtype)) << 3) & 0xff);
+ }
+
+ if (IFFUNC_ISBANKEDCALL (dtype) && !SPEC_STAT(getSpec(dtype)))
+ {
+ if (IFFUNC_CALLEESAVES(dtype))
+ {
+ werror (E_BANKED_WITH_CALLEESAVES);
+ }
+ else
+ {
+ char *l = aopLiteralLong (OP_VALUE (IC_LEFT (ic)), 0, 2);
+
+ emitcode ("mov", "r0,#%s", l);
+ emitcode ("mov", "r1,#(%s >> 8)", l);
+ emitcode ("mov", "r2,#(%s >> 16)", l);
+ emitcode ("lcall", "__sdcc_banked_call");
+ }
+ }
+ else
+ {
+ emitcode ("lcall", "%s", aopLiteralLong (OP_VALUE (IC_LEFT (ic)), 0, 2));
+ }
+ }
+ else
+ {
+ if (IFFUNC_ISBANKEDCALL (dtype) && !SPEC_STAT(getSpec(dtype)))
+ {
+ if (IFFUNC_CALLEESAVES(dtype))
+ {
+ werror (E_BANKED_WITH_CALLEESAVES);
+ }
+ else
+ {
+ aopOp (IC_LEFT (ic), ic, FALSE);
+
+ if (!swapBanks)
+ {
+ emitcode ("mov", "ar0,%s", aopGet(IC_LEFT (ic), 0, FALSE, FALSE));
+ emitcode ("mov", "ar1,%s", aopGet(IC_LEFT (ic), 1, FALSE, FALSE));
+ emitcode ("mov", "ar2,%s", aopGet(IC_LEFT (ic), 2, FALSE, FALSE));
+ }
+ else
+ {
+ int reg = ((FUNC_REGBANK(dtype)) << 3) & 0xff;
+ emitcode ("mov", "0x%02x,%s", reg++, aopGet(IC_LEFT (ic), 0, FALSE, FALSE));
+ emitcode ("mov", "0x%02x,%s", reg++, aopGet(IC_LEFT (ic), 1, FALSE, FALSE));
+ emitcode ("mov", "0x%02x,%s", reg, aopGet(IC_LEFT (ic), 2, FALSE, FALSE));
+ }
+
+ freeAsmop (IC_LEFT (ic), NULL, ic, TRUE);