short inLine;
short debugLine;
short nRegsSaved;
+ short dptrInUse;
+ short dptr1InUse;
set *sendSet;
}
_G;
short stack_val = -((sym->stack < 0) ?
((short) (sym->stack - _G.nRegsSaved)) :
((short) sym->stack)) ;
+ if (useDP2 && _G.dptr1InUse) {
+ emitcode ("push","dpl1");
+ emitcode ("push","dph1");
+ emitcode ("push","dpx1");
+ } else if (_G.dptrInUse ) {
+ emitcode ("push","dpl");
+ emitcode ("push","dph");
+ emitcode ("push","dpx");
+ }
/* It's on the 10 bit stack, which is located in
* far data space.
- */
+ */
if (stack_val < 0 && stack_val > -5) { /* between -5 & -1 */
if (useDP2) {
if (options.model == MODEL_FLAT24)
_G.r1Pushed--;
}
}
+ case AOP_DPTR2:
+ if (_G.dptr1InUse) {
+ emitcode ("pop","dpx1");
+ emitcode ("pop","dph1");
+ emitcode ("pop","dpl1");
+ }
+ break;
+ case AOP_DPTR:
+ if (_G.dptrInUse) {
+ emitcode ("pop","dpx");
+ emitcode ("pop","dph");
+ emitcode ("pop","dpl");
+ }
+ break;
}
-
dealloc:
/* all other cases just dealloc */
if (op)
MOVA (s);
}
{
- symbol *lbl = newiTempLabel (NULL);
- emitcode ("clr", "c");
- emitcode ("jz", "!tlabel", lbl->key + 100);
- emitcode ("cpl", "c");
- emitcode ("", "!tlabeldef", lbl->key + 100);
+ /* set C, if a >= 1 */
+ emitcode ("add", "a,#!constbyte",0xff);
emitcode ("mov", "%s,c", aop->aopu.aop_dir);
}
}
{
/* and the item is spilt then do nothing */
- if (OP_SYMBOL (IC_LEFT (ic))->isspilt)
+ if (OP_SYMBOL (IC_LEFT (ic))->isspilt || OP_SYMBOL(IC_LEFT(ic))->dptr)
return;
aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
/* if the temp was not pushed then */
- if (OP_SYMBOL (IC_LEFT (ic))->isspilt)
+ if (OP_SYMBOL (IC_LEFT (ic))->isspilt || OP_SYMBOL (IC_LEFT (ic))->dptr)
return;
aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
return TRUE;
}
+ if (AOP_TYPE(IC_RESULT(ic))==AOP_STR && IS_ITEMP(IC_RESULT(ic)) &&
+ !AOP_USESDPTR(IC_LEFT(ic)) && icount <= 5 && size <= 3 &&
+ options.model == MODEL_FLAT24 ) {
+
+ switch (size) {
+ case 3:
+ emitcode ("mov","dpx,%s",aopGet(AOP (IC_LEFT (ic)), 2, FALSE, FALSE, FALSE));
+ case 2:
+ emitcode ("mov","dph,%s",aopGet(AOP (IC_LEFT (ic)), 1, FALSE, FALSE, FALSE));
+ case 1:
+ emitcode ("mov","dpl,%s",aopGet(AOP (IC_LEFT (ic)), 0, FALSE, FALSE, FALSE));
+ break;
+ }
+ while (icount--) emitcode ("inc","dptr");
+ return TRUE;
+ }
+
if (AOP_INDPTRn(IC_LEFT(ic)) && AOP_INDPTRn(IC_RESULT(ic)) &&
AOP(IC_LEFT(ic))->aopu.dptr == AOP(IC_RESULT(ic))->aopu.dptr &&
icount <= 5 ) {
aopOp (IC_RIGHT (ic), ic, FALSE,
(AOP_INDPTRn(IC_LEFT(ic)) ? FALSE : (AOP_USESDPTR(IC_LEFT(ic)) ? TRUE : FALSE)));
if ((AOP_TYPE (IC_LEFT (ic)) == AOP_DPTR) &&
- (AOP_TYPE (IC_RIGHT (ic)) == AOP_DPTR2))
+ ((AOP_TYPE (IC_RIGHT (ic)) == AOP_DPTR2)
+ || OP_SYMBOL(IC_RESULT(ic))->ruonly))
{
pushResult = TRUE;
}
}
/*-----------------------------------------------------------------*/
-/* emitcodePointerGet - gget value from code space */
+/* genCodePointerGet - get value from code space */
/*-----------------------------------------------------------------*/
static void
-emitcodePointerGet (operand * left,
+genCodePointerGet (operand * left,
operand * result, iCode * ic, iCode *pi)
{
int size, offset, dopi=1;
else
{ /* we need to get it byte by byte */
_startLazyDPSEvaluation ();
+#if 1 // I see no point at all to this code and will likely yank it soon.
if (AOP(left)->type==AOP_DPTR2) {
char *l;
l=aopGet(AOP(left),0,FALSE,FALSE,TRUE);
} else {
emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE));
}
- } else {
+ }
+ else
+#endif
+ {
emitcode ("mov", "dpl,%s", aopGet (AOP(left),0,FALSE,FALSE,TRUE));
emitcode ("mov", "dph,%s", aopGet (AOP(left),1,FALSE,FALSE,TRUE));
if (options.model == MODEL_FLAT24) {
if (p_type == GPOINTER && OP_SYMBOL(left)->remat &&
IS_CAST_ICODE(OP_SYMBOL(left)->rematiCode)) {
left = IC_RIGHT(OP_SYMBOL(left)->rematiCode);
- type = type = operandType (left);
+ type = operandType (left);
p_type = DCL_TYPE (type);
}
/* now that we have the pointer type we assign
break;
case CPOINTER:
- emitcodePointerGet (left, result, ic, pi);
+ genCodePointerGet (left, result, ic, pi);
break;
case GPOINTER:
if (p_type == GPOINTER && OP_SYMBOL(result)->remat &&
IS_CAST_ICODE(OP_SYMBOL(result)->rematiCode)) {
result = IC_RIGHT(OP_SYMBOL(result)->rematiCode);
- type = type = operandType (result);
+ type = operandType (result);
p_type = DCL_TYPE (type);
}
case GPOINTER:
genGenPointerSet (right, result, ic, pi);
break;
+
+ default:
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "genPointerSet: illegal pointer type");
}
}
char buff[10];
tsprintf(buff,"#!constbyte",(options.stack_loc >> 16) & 0xff);
/* if it has an offset then we need to compute it */
- emitcode ("subb", "a,#!constbyte",
- -((sym->stack < 0) ?
- ((short) (sym->stack - _G.nRegsSaved)) :
- ((short) sym->stack)) & 0xff);
- emitcode ("mov","b,a");
- emitcode ("mov","a,#!constbyte",(-((sym->stack < 0) ?
- ((short) (sym->stack - _G.nRegsSaved)) :
- ((short) sym->stack)) >> 8) & 0xff);
+/* emitcode ("subb", "a,#!constbyte", */
+/* -((sym->stack < 0) ? */
+/* ((short) (sym->stack - _G.nRegsSaved)) : */
+/* ((short) sym->stack)) & 0xff); */
+/* emitcode ("mov","b,a"); */
+/* emitcode ("mov","a,#!constbyte",(-((sym->stack < 0) ? */
+/* ((short) (sym->stack - _G.nRegsSaved)) : */
+/* ((short) sym->stack)) >> 8) & 0xff); */
if (sym->stack) {
emitcode ("mov", "a,_bpx");
emitcode ("add", "a,#!constbyte", ((sym->stack < 0) ?
/* pointer to generic pointer */
if (IS_GENPTR (ctype))
{
- char *l = zero;
-
if (IS_PTR (type))
{
p_type = DCL_TYPE (type);
_endLazyDPSEvaluation ();
/* the last byte depending on type */
- switch (p_type)
{
- case IPOINTER:
- case POINTER:
- l = zero;
- break;
- case FPOINTER:
- l = one;
- break;
- case CPOINTER:
- l = "#0x02";
- break;
- case PPOINTER:
- l = "#0x03";
- break;
-
- default:
- /* this should never happen */
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "got unknown pointer type");
- exit (1);
+ int gpVal = pointerTypeToGPByte(p_type, NULL, NULL);
+ char gpValStr[10];
+
+ if (gpVal == -1)
+ {
+ // pointerTypeToGPByte will have bitched.
+ exit(1);
+ }
+
+ sprintf(gpValStr, "#0x%d", gpVal);
+ aopPut (AOP (result), gpValStr, GPTRSIZE - 1);
}
- aopPut (AOP (result), l, GPTRSIZE - 1);
goto release;
}
}
}
freeAsmop (to, NULL, ic, FALSE);
-
+ _G.dptrInUse = _G.dptr1InUse = 1;
aopOp (count, ic->next->next, FALSE,FALSE);
lbl =newiTempLabel(NULL);
/* now for the actual copy */
if (AOP_TYPE(count) == AOP_LIT &&
(int)floatFromVal (AOP(count)->aopu.aop_lit) <= 256) {
- emitcode (";","OH JOY auto increment with djnz (very fast)");
- emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
emitcode ("mov", "b,%s",aopGet(AOP(count),0,FALSE,FALSE,FALSE));
- emitcode ("","!tlabeldef",lbl->key+100);
if (fromc) {
- emitcode ("clr","a");
- emitcode ("movc", "a,@a+dptr");
- } else
- emitcode ("movx", "a,@dptr");
- emitcode ("movx", "@dptr,a");
- emitcode ("inc", "dptr");
- emitcode ("inc", "dptr");
- emitcode ("djnz","b,!tlabel",lbl->key+100);
+ emitcode ("lcall","__bi_memcpyc2x_s");
+ } else {
+ emitcode ("lcall","__bi_memcpyx2x_s");
+ }
+ freeAsmop (count, NULL, ic, FALSE);
} else {
symbol *lbl1 = newiTempLabel(NULL);
emitcode (";"," Auto increment but no djnz");
emitcode ("mov","_ap,%s",aopGet (AOP (count), 0, FALSE, TRUE, TRUE));
emitcode ("mov","b,%s",aopGet (AOP (count), 1, FALSE, TRUE, TRUE));
+ freeAsmop (count, NULL, ic, FALSE);
emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
emitcode ("","!tlabeldef",lbl->key+100);
if (fromc) {
emitcode ("","!tlabeldef",lbl1->key+100);
}
emitcode ("mov", "dps,#0");
- freeAsmop (count, NULL, ic, FALSE);
+ _G.dptrInUse = _G.dptr1InUse = 0;
unsavermask(rsave);
}
}
}
freeAsmop (to, NULL, ic, FALSE);
-
+ _G.dptrInUse = _G.dptr1InUse = 1;
aopOp (count, ic->next->next, FALSE,FALSE);
lbl =newiTempLabel(NULL);
lbl2 =newiTempLabel(NULL);
/* now for the actual compare */
- emitcode("push","ar0");
if (AOP_TYPE(count) == AOP_LIT &&
(int)floatFromVal (AOP(count)->aopu.aop_lit) <= 256) {
- emitcode (";","OH JOY auto increment with djnz (very fast)");
- emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
emitcode ("mov", "b,%s",aopGet(AOP(count),0,FALSE,FALSE,FALSE));
- emitcode ("","!tlabeldef",lbl->key+100);
- if (fromc) {
- emitcode ("clr","a");
- emitcode ("movc", "a,@a+dptr");
- } else
- emitcode ("movx", "a,@dptr");
- emitcode ("mov","r0,a");
- emitcode ("movx", "a,@dptr");
- emitcode ("clr","c");
- emitcode ("subb","a,r0");
- emitcode ("jnz","!tlabel",lbl2->key+100);
- emitcode ("inc", "dptr");
- emitcode ("inc", "dptr");
- emitcode ("djnz","b,!tlabel",lbl->key+100);
- emitcode ("clr","a");
+ if (fromc)
+ emitcode("lcall","__bi_memcmpc2x_s");
+ else
+ emitcode("lcall","__bi_memcmpx2x_s");
+ freeAsmop (count, NULL, ic, FALSE);
+ aopOp (IC_RESULT(ic), ic, FALSE,FALSE);
+ aopPut(AOP(IC_RESULT(ic)),"a",0);
+ freeAsmop (IC_RESULT(ic), NULL, ic, FALSE);
} else {
symbol *lbl1 = newiTempLabel(NULL);
-
+
+ emitcode("push","ar0");
emitcode (";"," Auto increment but no djnz");
emitcode ("mov","_ap,%s",aopGet (AOP (count), 0, FALSE, TRUE, TRUE));
emitcode ("mov","b,%s",aopGet (AOP (count), 1, FALSE, TRUE, TRUE));
+ freeAsmop (count, NULL, ic, FALSE);
emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
emitcode ("","!tlabeldef",lbl->key+100);
if (fromc) {
emitcode ("sjmp","!tlabel",lbl->key+100);
emitcode ("","!tlabeldef",lbl1->key+100);
emitcode ("clr","a");
+ emitcode ("","!tlabeldef",lbl2->key+100);
+ aopOp (IC_RESULT(ic), ic, FALSE,FALSE);
+ aopPut(AOP(IC_RESULT(ic)),"a",0);
+ freeAsmop (IC_RESULT(ic), NULL, ic, FALSE);
+ emitcode("pop","ar0");
+ emitcode ("mov", "dps,#0");
}
- freeAsmop (count, NULL, ic, FALSE);
- emitcode ("","!tlabeldef",lbl2->key+100);
- aopOp (IC_RESULT(ic), ic, FALSE,FALSE);
- aopPut(AOP(IC_RESULT(ic)),"a",0);
- freeAsmop (IC_RESULT(ic), NULL, ic, FALSE);
- emitcode("pop","ar0");
- emitcode ("mov", "dps,#0");
-
+ _G.dptrInUse = _G.dptr1InUse = 0;
unsavermask(rsave);
}
}
freeAsmop (to, NULL, ic, FALSE);
+ _G.dptrInUse = _G.dptr1InUse = 1;
aopOp (count, ic->next->next, FALSE,FALSE);
lbl =newiTempLabel(NULL);
emitcode (";","OH JOY auto increment with djnz (very fast)");
emitcode ("mov", "dps,#!constbyte",0x1); /* Select DPTR2 */
emitcode ("mov", "b,%s",aopGet(AOP(count),0,FALSE,FALSE,FALSE));
+ freeAsmop (count, NULL, ic, FALSE);
emitcode ("","!tlabeldef",lbl->key+100);
emitcode ("movx", "a,@dptr"); /* read data from port */
emitcode ("dec","dps"); /* switch to DPTR */
emitcode (";"," Auto increment but no djnz");
emitcode ("mov","_ap,%s",aopGet (AOP (count), 0, FALSE, TRUE, TRUE));
emitcode ("mov","b,%s",aopGet (AOP (count), 1, FALSE, TRUE, TRUE));
+ freeAsmop (count, NULL, ic, FALSE);
emitcode ("mov", "dps,#!constbyte",0x1); /* Select DPTR2 */
emitcode ("","!tlabeldef",lbl->key+100);
emitcode ("movx", "a,@dptr");
emitcode ("","!tlabeldef",lbl1->key+100);
}
emitcode ("mov", "dps,#0");
- freeAsmop (count, NULL, ic, FALSE);
+ _G.dptrInUse = _G.dptr1InUse = 0;
unsavermask(rsave);
}
}
freeAsmop (to, NULL, ic, FALSE);
+ _G.dptrInUse = _G.dptr1InUse = 1;
aopOp (count, ic->next->next, FALSE,FALSE);
lbl =newiTempLabel(NULL);
emitcode ("inc", "dptr"); /* point to next area */
emitcode ("dec","dps"); /* switch to DPTR */
emitcode ("djnz","b,!tlabel",lbl->key+100);
+ freeAsmop (count, NULL, ic, FALSE);
} else {
symbol *lbl1 = newiTempLabel(NULL);
emitcode (";"," Auto increment but no djnz");
emitcode ("mov","_ap,%s",aopGet (AOP (count), 0, FALSE, TRUE, TRUE));
emitcode ("mov","b,%s",aopGet (AOP (count), 1, FALSE, TRUE, TRUE));
+ freeAsmop (count, NULL, ic, FALSE);
emitcode ("mov", "dps,#!constbyte",0x0); /* Select DPTR */
emitcode ("","!tlabeldef",lbl->key+100);
-/* emitcode ("push","acc"); */
emitcode ("movx", "a,@dptr");
emitcode ("inc", "dptr");
emitcode ("inc","dps"); /* switch to DPTR2 */
emitcode ("movx", "@dptr,a");
emitcode ("dec","dps"); /* switch to DPTR */
-/* emitcode ("pop","acc"); */
-/* emitcode ("djnz","acc,!tlabel",lbl->key+100); */
-/* emitcode ("djnz","b,!tlabel",lbl->key+100); */
emitcode ("mov","a,b");
emitcode ("orl","a,_ap");
emitcode ("jz","!tlabel",lbl1->key+100);
emitcode ("","!tlabeldef",lbl1->key+100);
}
emitcode ("mov", "dps,#0");
- freeAsmop (count, NULL, ic, FALSE);
+ _G.dptrInUse = _G.dptr1InUse = 0;
unsavermask(rsave);
}