- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
-
- if (AOP_NEEDSACC(IC_RESULT(ic)))
- {
- /* If the result is accessed indirectly via
- * the accumulator, we must explicitly write
- * it back after the decrement.
- */
- char *rByte = aopGet(AOP(IC_RESULT(ic)), 0, FALSE, FALSE, TRUE);
-
- if (strcmp(rByte, "a"))
- {
- /* Something is hopelessly wrong */
- fprintf(stderr, "*** warning: internal error at %s:%d\n",
- __FILE__, __LINE__);
- /* We can just give up; the generated code will be inefficient,
- * but what the hey.
- */
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
- return 0;
- }
- emitcode ("dec", "%s", rByte);
- aopPut(AOP(IC_RESULT(ic)), rByte, 0);
- emitcode ("jnz", "!tlabel", lbl->key + 100);
- }
- else if (IS_AOP_PREG (IC_RESULT (ic)))
- {
- emitcode ("dec", "%s",
- aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE, FALSE));
- emitcode ("mov", "a,%s", aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE, FALSE));
- emitcode ("jnz", "!tlabel", lbl->key + 100);
- }
- else
- {
- emitcode ("djnz", "%s,!tlabel", aopGet (AOP (IC_RESULT (ic)), 0, FALSE, TRUE, FALSE),
- lbl->key + 100);
- }
- emitcode ("sjmp", "!tlabel", lbl1->key + 100);
- emitcode ("", "!tlabeldef", lbl->key + 100);
- emitcode ("ljmp", "!tlabel", IC_TRUE (ifx)->key + 100);
- emitcode ("", "!tlabeldef", lbl1->key + 100);
-
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
- ifx->generated = 1;
- return 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* genReceive - generate code for a receive iCode */
-/*-----------------------------------------------------------------*/
-static void
-genReceive (iCode * ic)
-{
-
- int size = getSize (operandType (IC_RESULT (ic)));
- int offset = 0;
- int rb1off ;
-
- D (emitcode (";", "genReceive ");
- );
-
- if (ic->argreg == 1) { /* first parameter */
- if (isOperandInFarSpace (IC_RESULT (ic)) &&
- (OP_SYMBOL (IC_RESULT (ic))->isspilt ||
- IS_TRUE_SYMOP (IC_RESULT (ic))))
- {
- offset = fReturnSizeDS390 - size;
- while (size--)
- {
- emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeDS390 - offset - 1], "a") ?
- fReturn[fReturnSizeDS390 - offset - 1] : "acc"));
- offset++;
- }
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
- size = AOP_SIZE (IC_RESULT (ic));
- offset = 0;
- while (size--)
- {
- emitcode ("pop", "acc");
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
- }
-
- } else {
- _G.accInUse++;
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
- _G.accInUse--;
- assignResultValue (IC_RESULT (ic));
- }
- } else { /* second receive onwards */
- /* this gets a little tricky since unused recevies will be
- eliminated, we have saved the reg in the type field . and
- we use that to figure out which register to use */
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
- rb1off = ic->argreg;
- while (size--) {
- aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++);
- }
-
- }
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genMemcpyX2X - gen code for memcpy xdata to xdata */
-/*-----------------------------------------------------------------*/
-static void genMemcpyX2X( iCode *ic, int nparms, operand **parms, int fromc)
-{
- operand *from , *to , *count;
- symbol *lbl;
- 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, TRUE));
- emitcode ("mov", "dph1,%s", aopGet (AOP (from), 1, FALSE, FALSE, TRUE));
- if (options.model == MODEL_FLAT24) {
- emitcode ("mov", "dpx1,%s", aopGet (AOP (from), 2, FALSE, FALSE, TRUE));
- }
-
- 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, TRUE));
- emitcode ("push", "%s", aopGet (AOP (to), 1, FALSE, TRUE, TRUE));
- if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx,%s", aopGet (AOP (to), 2, FALSE, FALSE, TRUE));
- 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, FALSE));
- } else { /* we need to get it byte by byte */
- emitcode ("mov", "dpl,%s", aopGet (AOP (to), 0, FALSE, FALSE, TRUE));
- emitcode ("mov", "dph,%s", aopGet (AOP (to), 1, FALSE, FALSE, TRUE));
- if (options.model == MODEL_FLAT24) {
- emitcode ("mov", "dpx,%s", aopGet (AOP (to), 2, FALSE, FALSE, TRUE));
- }
- }
- _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,FALSE));
- 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, 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 ("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);
+ /* now for the actual copy */
+ if (AOP_TYPE(count) == AOP_LIT &&
+ (int)floatFromVal (AOP(count)->aopu.aop_lit) <= 256) {
+ emitcode ("mov", "b,%s",aopGet(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 (count, 0, FALSE, TRUE, NULL));
+ emitcode ("mov","b,%s",aopGet (count, 1, FALSE, TRUE, NULL));
+ freeAsmop (count, NULL, ic, FALSE);
+ emitcode ("mov", "dps,#!constbyte",0x21); /* Select DPTR2 & auto-toggle. */
+ emitLabel (lbl);
+ 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);
+ emitLabel (lbl1);
+ }
+ emitcode ("mov", "dps,#0");
+ _G.dptrInUse = _G.dptr1InUse = 0;
+ unsavermask(rsave);