+
+ rsave = newBitVect(16);
+ /* save DPTR if it needs to be saved */
+ for (i = DPL_IDX ; i <= B_IDX ; i++ ) {
+ if (bitVectBitValue(ic->rMask,i))
+ rsave = bitVectSetBit(rsave,i);
+ }
+ rsave = bitVectIntersect(rsave,bitVectCplAnd (bitVectCopy (ic->rMask),
+ ds390_rUmaskForOp (IC_RESULT(ic))));
+ savermask(rsave);
+
+ to = parms[0];
+ from = parms[1];
+ count = parms[2];
+
+ aopOp (from, ic->next, FALSE, FALSE);
+
+ /* get from into DPTR1 */
+ emitcode ("mov", "dpl1,%s", aopGet (AOP (from), 0, FALSE, FALSE, NULL));
+ emitcode ("mov", "dph1,%s", aopGet (AOP (from), 1, FALSE, FALSE, NULL));
+ if (options.model == MODEL_FLAT24) {
+ emitcode ("mov", "dpx1,%s", aopGet (AOP (from), 2, FALSE, FALSE, NULL));
+ }
+
+ freeAsmop (from, NULL, ic, FALSE);
+ aopOp (to, ic, FALSE, FALSE);
+ /* get "to" into DPTR */
+ /* if the operand is already in dptr
+ then we do nothing else we move the value to dptr */
+ if (AOP_TYPE (to) != AOP_STR) {
+ /* if already in DPTR then we need to push */
+ if (AOP_TYPE(to) == AOP_DPTR) {
+ emitcode ("push", "%s", aopGet (AOP (to), 0, FALSE, TRUE, NULL));
+ emitcode ("push", "%s", aopGet (AOP (to), 1, FALSE, TRUE, NULL));
+ if (options.model == MODEL_FLAT24)
+ emitcode ("mov", "dpx,%s", aopGet (AOP (to), 2, FALSE, FALSE, NULL));
+ emitcode ("pop", "dph");
+ emitcode ("pop", "dpl");
+ } else {
+ _startLazyDPSEvaluation ();
+ /* if this is remateriazable */
+ if (AOP_TYPE (to) == AOP_IMMD) {
+ emitcode ("mov", "dptr,%s", aopGet (AOP (to), 0, TRUE, FALSE, NULL));
+ } else { /* we need to get it byte by byte */
+ emitcode ("mov", "dpl,%s", aopGet (AOP (to), 0, FALSE, FALSE, NULL));
+ emitcode ("mov", "dph,%s", aopGet (AOP (to), 1, FALSE, FALSE, NULL));
+ if (options.model == MODEL_FLAT24) {
+ emitcode ("mov", "dpx,%s", aopGet (AOP (to), 2, FALSE, FALSE, NULL));
+ }
+ }
+ _endLazyDPSEvaluation ();
+ }
+ }
+ 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 ("mov", "b,%s",aopGet(AOP(count),0,FALSE,FALSE,NULL));
+ if (fromc) {
+ 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, NULL));
+ emitcode ("mov","b,%s",aopGet (AOP (count), 1, FALSE, TRUE, NULL));
+ freeAsmop (count, NULL, ic, FALSE);
+ emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
+ 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 ("mov","a,b");
+ emitcode ("orl","a,_ap");
+ emitcode ("jz","!tlabel",lbl1->key+100);
+ emitcode ("mov","a,_ap");
+ emitcode ("add","a,#!constbyte",0xFF);
+ emitcode ("mov","_ap,a");
+ emitcode ("mov","a,b");
+ emitcode ("addc","a,#!constbyte",0xFF);
+ emitcode ("mov","b,a");
+ emitcode ("sjmp","!tlabel",lbl->key+100);
+ emitcode ("","!tlabeldef",lbl1->key+100);
+ }
+ emitcode ("mov", "dps,#0");
+ _G.dptrInUse = _G.dptr1InUse = 0;
+ unsavermask(rsave);
+
+}
+
+/*-----------------------------------------------------------------*/
+/* genMemcmpX2X - gen code for memcmp xdata to xdata */
+/*-----------------------------------------------------------------*/
+static void genMemcmpX2X( iCode *ic, int nparms, operand **parms, int fromc)
+{
+ operand *from , *to , *count;
+ symbol *lbl,*lbl2;
+ bitVect *rsave;
+ int i;
+
+ /* we know it has to be 3 parameters */
+ assert (nparms == 3);
+
+ rsave = newBitVect(16);
+ /* save DPTR if it needs to be saved */
+ for (i = DPL_IDX ; i <= B_IDX ; i++ ) {
+ if (bitVectBitValue(ic->rMask,i))
+ rsave = bitVectSetBit(rsave,i);
+ }
+ rsave = bitVectIntersect(rsave,bitVectCplAnd (bitVectCopy (ic->rMask),
+ ds390_rUmaskForOp (IC_RESULT(ic))));
+ savermask(rsave);
+
+ to = parms[0];
+ from = parms[1];
+ count = parms[2];
+
+ aopOp (from, ic->next, FALSE, FALSE);
+
+ /* get from into DPTR1 */
+ emitcode ("mov", "dpl1,%s", aopGet (AOP (from), 0, FALSE, FALSE, NULL));
+ emitcode ("mov", "dph1,%s", aopGet (AOP (from), 1, FALSE, FALSE, NULL));
+ if (options.model == MODEL_FLAT24) {
+ emitcode ("mov", "dpx1,%s", aopGet (AOP (from), 2, FALSE, FALSE, NULL));
+ }
+
+ freeAsmop (from, NULL, ic, FALSE);
+ aopOp (to, ic, FALSE, FALSE);
+ /* get "to" into DPTR */
+ /* if the operand is already in dptr
+ then we do nothing else we move the value to dptr */
+ if (AOP_TYPE (to) != AOP_STR) {
+ /* if already in DPTR then we need to push */
+ if (AOP_TYPE(to) == AOP_DPTR) {
+ emitcode ("push", "%s", aopGet (AOP (to), 0, FALSE, TRUE, NULL));
+ emitcode ("push", "%s", aopGet (AOP (to), 1, FALSE, TRUE, NULL));
+ if (options.model == MODEL_FLAT24)
+ emitcode ("mov", "dpx,%s", aopGet (AOP (to), 2, FALSE, FALSE, NULL));
+ emitcode ("pop", "dph");
+ emitcode ("pop", "dpl");
+ } else {
+ _startLazyDPSEvaluation ();
+ /* if this is remateriazable */
+ if (AOP_TYPE (to) == AOP_IMMD) {
+ emitcode ("mov", "dptr,%s", aopGet (AOP (to), 0, TRUE, FALSE, NULL));
+ } else { /* we need to get it byte by byte */
+ emitcode ("mov", "dpl,%s", aopGet (AOP (to), 0, FALSE, FALSE, NULL));
+ emitcode ("mov", "dph,%s", aopGet (AOP (to), 1, FALSE, FALSE, NULL));
+ if (options.model == MODEL_FLAT24) {
+ emitcode ("mov", "dpx,%s", aopGet (AOP (to), 2, FALSE, FALSE, NULL));
+ }
+ }
+ _endLazyDPSEvaluation ();
+ }
+ }
+ 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 */
+ if (AOP_TYPE(count) == AOP_LIT &&
+ (int)floatFromVal (AOP(count)->aopu.aop_lit) <= 256) {
+ emitcode ("mov", "b,%s",aopGet(AOP(count),0,FALSE,FALSE,NULL));
+ 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, NULL));
+ emitcode ("mov","b,%s",aopGet (AOP (count), 1, FALSE, TRUE, NULL));
+ freeAsmop (count, NULL, ic, FALSE);
+ emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
+ 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 ("mov","a,b");
+ emitcode ("orl","a,_ap");
+ emitcode ("jz","!tlabel",lbl1->key+100);
+ emitcode ("mov","a,_ap");
+ emitcode ("add","a,#!constbyte",0xFF);
+ emitcode ("mov","_ap,a");
+ emitcode ("mov","a,b");
+ emitcode ("addc","a,#!constbyte",0xFF);
+ emitcode ("mov","b,a");
+ 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");
+ }
+ _G.dptrInUse = _G.dptr1InUse = 0;
+ unsavermask(rsave);
+
+}
+
+/*-----------------------------------------------------------------*/
+/* genInp - gen code for __builtin_inp read data from a mem mapped */
+/* port, first parameter output area second parameter pointer to */
+/* port third parameter count */
+/*-----------------------------------------------------------------*/
+static void genInp( iCode *ic, int nparms, operand **parms)
+{
+ operand *from , *to , *count;
+ symbol *lbl;
+ bitVect *rsave;
+ int i;
+
+ /* we know it has to be 3 parameters */
+ assert (nparms == 3);
+