-static void
-genDivOneByte (operand * left,
- operand * right,
- operand * result)
-{
- sym_link *opetype = operandType (result);
- char *l;
- symbol *lbl;
- int size, offset;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- size = AOP_SIZE (result) - 1;
- offset = 1;
- /* signed or unsigned */
- if (SPEC_USIGN (opetype))
- {
- /* unsigned is easy */
- emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
- emitcode ("div", "ab");
- aopPut (AOP (result), "a", 0);
- while (size--)
- aopPut (AOP (result), zero, offset++);
- return;
- }
-
- /* signed is a little bit more difficult */
-
- /* save the signs of the operands */
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
- emitcode ("xrl", "a,%s", aopGet (AOP (right), 0, FALSE, TRUE));
- emitcode ("push", "acc"); /* save it on the stack */
-
- /* now sign adjust for both left & right */
- l = aopGet (AOP (right), 0, FALSE, FALSE);
- MOVA (l);
- lbl = newiTempLabel (NULL);
- emitcode ("jnb", "acc.7,%05d_DS_", (lbl->key + 100));
- emitcode ("cpl", "a");
- emitcode ("inc", "a");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
- emitcode ("mov", "b,a");
-
- /* sign adjust left side */
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
-
- lbl = newiTempLabel (NULL);
- emitcode ("jnb", "acc.7,%05d_DS_", (lbl->key + 100));
- emitcode ("cpl", "a");
- emitcode ("inc", "a");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
-
- /* now the division */
- emitcode ("div", "ab");
- /* we are interested in the lower order
- only */
- emitcode ("mov", "b,a");
- lbl = newiTempLabel (NULL);
- emitcode ("pop", "acc");
- /* if there was an over flow we don't
- adjust the sign of the result */
- emitcode ("jb", "ov,%05d_DS_", (lbl->key + 100));
- emitcode ("jnb", "acc.7,%05d_DS_", (lbl->key + 100));
- CLRC;
- emitcode ("clr", "a");
- emitcode ("subb", "a,b");
- emitcode ("mov", "b,a");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
-
- /* now we are done */
- aopPut (AOP (result), "b", 0);
- if (size > 0)
- {
- emitcode ("mov", "c,b.7");
- emitcode ("subb", "a,acc");
- }
- while (size--)
- aopPut (AOP (result), "a", offset++);
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genDiv - generates code for division */
-/*-----------------------------------------------------------------*/
-static void
-genDiv (iCode * ic)
-{
- operand *left = IC_LEFT (ic);
- operand *right = IC_RIGHT (ic);
- operand *result = IC_RESULT (ic);
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* assign the amsops */
- aopOp (left, ic, FALSE);
- aopOp (right, ic, FALSE);
- aopOp (result, ic, TRUE);
-
- /* special cases first */
- /* both are bits */
- if (AOP_TYPE (left) == AOP_CRY &&
- AOP_TYPE (right) == AOP_CRY)
- {
- genDivbits (left, right, result);
- goto release;
- }
-
- /* if both are of size == 1 */
- if (AOP_SIZE (left) == 1 &&
- AOP_SIZE (right) == 1)
- {
- genDivOneByte (left, right, result);
- goto release;
- }
-
- /* should have been converted to function call */
- assert (1);
-release:
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genModbits :- modulus of bits */
-/*-----------------------------------------------------------------*/
-static void
-genModbits (operand * left,
- operand * right,
- operand * result)
-{
-
- char *l;
-
- /* the result must be bit */
- emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- l = aopGet (AOP (left), 0, FALSE, FALSE);
-
- MOVA (l);
-
- emitcode ("div", "ab");
- emitcode ("mov", "a,b");
- emitcode ("rrc", "a");
- aopPut (AOP (result), "c", 0);
-}
-
-/*-----------------------------------------------------------------*/
-/* genModOneByte : 8 bit modulus */
-/*-----------------------------------------------------------------*/
-static void
-genModOneByte (operand * left,
- operand * right,
- operand * result)
-{
- sym_link *opetype = operandType (result);
- char *l;
- symbol *lbl;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* signed or unsigned */
- if (SPEC_USIGN (opetype))
- {
- /* unsigned is easy */
- emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
- emitcode ("div", "ab");
- aopPut (AOP (result), "b", 0);
- return;
- }
-
- /* signed is a little bit more difficult */
-
- /* save the signs of the operands */
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
-
- emitcode ("xrl", "a,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- emitcode ("push", "acc"); /* save it on the stack */
-
- /* now sign adjust for both left & right */
- l = aopGet (AOP (right), 0, FALSE, FALSE);
- MOVA (l);
-
- lbl = newiTempLabel (NULL);
- emitcode ("jnb", "acc.7,%05d_DS_", (lbl->key + 100));
- emitcode ("cpl", "a");
- emitcode ("inc", "a");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
- emitcode ("mov", "b,a");
-
- /* sign adjust left side */
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
-
- lbl = newiTempLabel (NULL);
- emitcode ("jnb", "acc.7,%05d_DS_", (lbl->key + 100));
- emitcode ("cpl", "a");
- emitcode ("inc", "a");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
-
- /* now the multiplication */
- emitcode ("div", "ab");
- /* we are interested in the lower order
- only */
- lbl = newiTempLabel (NULL);
- emitcode ("pop", "acc");
- /* if there was an over flow we don't
- adjust the sign of the result */
- emitcode ("jb", "ov,%05d_DS_", (lbl->key + 100));
- emitcode ("jnb", "acc.7,%05d_DS_", (lbl->key + 100));
- CLRC;
- emitcode ("clr", "a");
- emitcode ("subb", "a,b");
- emitcode ("mov", "b,a");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
-
- /* now we are done */
- aopPut (AOP (result), "b", 0);
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genMod - generates code for division */
-/*-----------------------------------------------------------------*/
-static void
-genMod (iCode * ic)
-{
- operand *left = IC_LEFT (ic);
- operand *right = IC_RIGHT (ic);
- operand *result = IC_RESULT (ic);
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* assign the amsops */
- aopOp (left, ic, FALSE);
- aopOp (right, ic, FALSE);
- aopOp (result, ic, TRUE);
-
- /* special cases first */
- /* both are bits */
- if (AOP_TYPE (left) == AOP_CRY &&
- AOP_TYPE (right) == AOP_CRY)
- {
- genModbits (left, right, result);
- goto release;
- }
-
- /* if both are of size == 1 */
- if (AOP_SIZE (left) == 1 &&
- AOP_SIZE (right) == 1)
- {
- genModOneByte (left, right, result);
- goto release;
- }
-
- /* should have been converted to function call */
- assert (1);
-
-release:
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genIfxJump :- will create a jump depending on the ifx */
-/*-----------------------------------------------------------------*/
-static void
-genIfxJump (iCode * ic, char *jval)
-{
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* if true label then we jump if condition
- supplied is true */
- if (IC_TRUE (ic))
- {
-
- if (strcmp (jval, "a") == 0)
- emitSKPZ;
- else if (strcmp (jval, "c") == 0)
- emitSKPC;
- else
- emitcode ("btfsc", "(%s >> 3),(%s & 7)", jval, jval);
-
- emitcode (" goto", "_%05d_DS_", IC_TRUE (ic)->key + 100 + labelOffset);
-
- }
- else
- {
- /* false label is present */
- if (strcmp (jval, "a") == 0)
- emitSKPNZ;
- else if (strcmp (jval, "c") == 0)
- emitSKPNC;
- else
- emitcode ("btfss", "(%s >> 3),(%s & 7)", jval, jval);
-
- emitcode (" goto", "_%05d_DS_", IC_FALSE (ic)->key + 100 + labelOffset);
-
- }
-
-
- /* mark the icode as generated */
- ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* genSkip */
-/*-----------------------------------------------------------------*/
-static void
-genSkip (iCode * ifx, int status_bit)
-{
- if (!ifx)
- return;
-
- if (IC_TRUE (ifx))
- {
- switch (status_bit)
- {
- case 'z':
- emitSKPNZ;
- break;
-
- case 'c':
- emitSKPNC;
- break;
-
- case 'd':
- emitcode ("skpndc", "");
- break;
-
- }
-
- emitcode ("goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
-
- }
- else
- {
-
- switch (status_bit)
- {
-
- case 'z':
- emitSKPZ;
- break;
-
- case 'c':
- emitSKPC;
- break;
-
- case 'd':
- emitcode ("skpdc", "");
- break;
- }
- emitcode ("goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
-
- }
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genSkipc */
-/*-----------------------------------------------------------------*/
-static void
-genSkipc (iCode * ifx, int condition)
-{
- if (!ifx)
- return;
-
- if (condition)
- emitSKPNC;
- else
- emitSKPC;
-
- if (IC_TRUE (ifx))
- emitcode ("goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
- else
- emitcode ("goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genSkipz */
-/*-----------------------------------------------------------------*/
-static void
-genSkipz (iCode * ifx, int condition)
-{
- if (!ifx)
- return;
-
- if (condition)
- emitSKPNZ;
- else
- emitSKPZ;
-
- if (IC_TRUE (ifx))
- emitcode ("goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
- else
- emitcode ("goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
-
-}
-/*-----------------------------------------------------------------*/
-/* genCmp :- greater or less than comparison */
-/*-----------------------------------------------------------------*/
-static void
-genCmp (operand * left, operand * right,
- operand * result, iCode * ifx, int sign)
-{
- int size, offset = 0;
- unsigned long lit = 0L, i = 0;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* if left & right are bit variables */
- if (AOP_TYPE (left) == AOP_CRY &&
- AOP_TYPE (right) == AOP_CRY)
- {
- emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- emitcode ("anl", "c,/%s", AOP (left)->aopu.aop_dir);
- }
- else
- {
- /* subtract right from left if at the
- end the carry flag is set then we know that
- left is greater than right */
- size = max (AOP_SIZE (left), AOP_SIZE (right));
-
- /* if unsigned char cmp with lit, do cjne left,#right,zz */
- if ((size == 1) && !sign &&
- (AOP_TYPE (right) == AOP_LIT && AOP_TYPE (left) != AOP_DIR))
- {
- symbol *lbl = newiTempLabel (NULL);
- emitcode ("cjne", "%s,%s,%05d_DS_",
- aopGet (AOP (left), offset, FALSE, FALSE),
- aopGet (AOP (right), offset, FALSE, FALSE),
- lbl->key + 100);
- emitcode ("", "%05d_DS_:", lbl->key + 100);
- }
- else
- {
-
- if (AOP_TYPE (right) == AOP_LIT)
- {
-
- DEBUGemitcode (";right lit", "%d", sign);
-
- lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
- //default:
- while (size--)
- {
- i = (lit >> (size * 8)) & 0xff;
- if (i == 0)
- {
- emitcode ("movf", "%s,w", aopGet (AOP (left), size, FALSE, FALSE));
- genSkipz (ifx, IC_TRUE (ifx) == NULL);
- }
- else
- {
- emitcode ("movlw", "0x%x", i);
- emitcode ("subwf", "%s,w", aopGet (AOP (left), size, FALSE, FALSE));
- genSkipc (ifx, IC_TRUE (ifx) == NULL);
- }
-
- }
- ifx->generated = 1;
- return;
- }
- if (AOP_TYPE (left) == AOP_LIT)
- {
-
- DEBUGemitcode (";left lit", "%d", sign);
-
- lit = (unsigned long) (floatFromVal (AOP (left)->aopu.aop_lit)) + 1;
-
- //default:
- while (size--)
- {
- i = (lit >> (size * 8)) & 0xff;
- if (i == 0)
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), size, FALSE, FALSE));
- genSkipz (ifx, IC_TRUE (ifx) != NULL);
- }
- else if (i == 1)
- {
- emitcode ("decf", "%s,w", aopGet (AOP (right), size, FALSE, FALSE));
- genSkipz (ifx, IC_TRUE (ifx) != NULL);
-
- }
- else
- {
- emitcode ("movlw", "0x%x", i);
- emitcode ("subwf", "%s,w", aopGet (AOP (right), size, FALSE, FALSE));
- genSkipc (ifx, IC_TRUE (ifx) != NULL);
- }
- }
- ifx->generated = 1;
- return;
- }
-
-
- // CLRC;
- DEBUGemitcode (";sign", "%d", sign);
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("subwf", "%s,w", aopGet (AOP (left), offset++, FALSE, FALSE));
- size--;
- while (size--)
- {
-
- /*if (AOP_TYPE(right) == AOP_LIT){
- unsigned long lit = (unsigned long)
- floatFromVal(AOP(right)->aopu.aop_lit);
- emitcode("subb","a,#0x%02x",
- 0x80 ^ (unsigned int)((lit >> (offset*8)) & 0x0FFL));
- } else {
- emitcode("mov","b,%s",aopGet(AOP(right),offset++,FALSE,FALSE));
- emitcode("xrl","b,#0x80");
- emitcode("subb","a,b");
- }
- } else
- emitcode("subb","a,%s",aopGet(AOP(right),offset++,FALSE,FALSE));
- */
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitSKPC;
- emitcode ("incfsz", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("subwf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- offset++;
- }
- }
- }
-
- //release:
- if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
- {
- outBitC (result);
- }
- else
- {
- /* if the result is used in the next
- ifx conditional branch then generate
- code a little differently */
- if (ifx)
- genIfxJump (ifx, "c");
- else
- outBitC (result);
- /* leave the result in acc */
- }
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genCmpGt :- greater than comparison */
-/*-----------------------------------------------------------------*/
-static void
-genCmpGt (iCode * ic, iCode * ifx)
-{
- operand *left, *right, *result;
- sym_link *letype, *retype;
- int sign;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- left = IC_LEFT (ic);
- right = IC_RIGHT (ic);
- result = IC_RESULT (ic);
-
- letype = getSpec (operandType (left));
- retype = getSpec (operandType (right));
- sign = !(SPEC_USIGN (letype) | SPEC_USIGN (retype));
- /* assign the amsops */
- aopOp (left, ic, FALSE);
- aopOp (right, ic, FALSE);
- aopOp (result, ic, TRUE);
-
- genCmp (right, left, result, ifx, sign);
-
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genCmpLt - less than comparisons */
-/*-----------------------------------------------------------------*/
-static void
-genCmpLt (iCode * ic, iCode * ifx)
-{
- operand *left, *right, *result;
- sym_link *letype, *retype;
- int sign;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- left = IC_LEFT (ic);
- right = IC_RIGHT (ic);
- result = IC_RESULT (ic);
-
- letype = getSpec (operandType (left));
- retype = getSpec (operandType (right));
- sign = !(SPEC_USIGN (letype) | SPEC_USIGN (retype));
-
- /* assign the amsops */
- aopOp (left, ic, FALSE);
- aopOp (right, ic, FALSE);
- aopOp (result, ic, TRUE);
-
- genCmp (left, right, result, ifx, sign);
-
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* gencjneshort - compare and jump if not equal */
-/*-----------------------------------------------------------------*/
-static void
-gencjneshort (operand * left, operand * right, symbol * lbl)
-{
- int size = max (AOP_SIZE (left), AOP_SIZE (right));
- int offset = 0;
- unsigned long lit = 0L;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* if the left side is a literal or
- if the right is in a pointer register and left
- is not */
- if ((AOP_TYPE (left) == AOP_LIT) ||
- (IS_AOP_PREG (right) && !IS_AOP_PREG (left)))
- {
- operand *t = right;
- right = left;
- left = t;
- }
- if (AOP_TYPE (right) == AOP_LIT)
- lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
-
- /* if the right side is a literal then anything goes */
- if (AOP_TYPE (right) == AOP_LIT &&
- AOP_TYPE (left) != AOP_DIR)
- {
- while (size--)
- {
- if (lit & 0xff)
- {
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("xorlw", "0x%x", lit & 0xff);
- }
- else
- emitcode ("movf", "%s,f", aopGet (AOP (left), offset, FALSE, FALSE));
-
- emitSKPNZ;
- emitcode ("goto", "_%05d_DS_", lbl->key + 100 + labelOffset);
- offset++;
- lit >>= 8;
- }
- }
-
- /* if the right side is in a register or in direct space or
- if the left is a pointer register & right is not */
- else if (AOP_TYPE (right) == AOP_REG ||
- AOP_TYPE (right) == AOP_DIR ||
- (AOP_TYPE (left) == AOP_DIR && AOP_TYPE (right) == AOP_LIT) ||
- (IS_AOP_PREG (left) && !IS_AOP_PREG (right)))
- {
- while (size--)
- {
- if ((AOP_TYPE (left) == AOP_DIR && AOP_TYPE (right) == AOP_LIT) &&
- ((lit & 0xff) != 0))
- {
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("xorlw", "0x%x", lit & 0xff);
- lit >>= 8;
- }
- else
- emitcode ("movf", "%s,f", aopGet (AOP (left), offset, FALSE, FALSE));
-
- emitSKPZ;
- emitcode ("goto", "_%05d_DS_", lbl->key + 100 + labelOffset);
- offset++;
-/*
- MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
- if((AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) &&
- ((unsigned int)((lit >> (offset*8)) & 0x0FFL) == 0))
- emitcode("jnz","%05d_DS_",lbl->key+100);
- else
- emitcode("cjne","a,%s,%05d_DS_",
- aopGet(AOP(right),offset,FALSE,TRUE),
- lbl->key+100);
- offset++;
- */
- }
- }
- else
- {
- /* right is a pointer reg need both a & b */
- while (size--)
- {
- char *l = aopGet (AOP (left), offset, FALSE, FALSE);
- if (strcmp (l, "b"))
- emitcode ("mov", "b,%s", l);
- MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("cjne", "a,b,%05d_DS_", lbl->key + 100);
- offset++;
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* gencjne - compare and jump if not equal */
-/*-----------------------------------------------------------------*/
-static void
-gencjne (operand * left, operand * right, symbol * lbl)
-{
- symbol *tlbl = newiTempLabel (NULL);
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- gencjneshort (left, right, lbl);
-
- emitcode ("mov", "a,%s", one);
- emitcode ("sjmp", "%05d_DS_", tlbl->key + 100);
- emitcode ("", "%05d_DS_:", lbl->key + 100);
- emitcode ("clr", "a");
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
-}
-
-
-/*-----------------------------------------------------------------*/
-/* genCmpEq - generates code for equal to */
-/*-----------------------------------------------------------------*/
-static void
-genCmpEq (iCode * ic, iCode * ifx)
-{
- operand *left, *right, *result;
- unsigned long lit = 0L;
- int size, offset = 0;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (ifx)
- DEBUGemitcode ("; ifx is non-null", "");
- else
- DEBUGemitcode ("; ifx is null", "");
-
- aopOp ((left = IC_LEFT (ic)), ic, FALSE);
- aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
- aopOp ((result = IC_RESULT (ic)), ic, TRUE);
-
- size = max (AOP_SIZE (left), AOP_SIZE (right));
-
- /* if literal, literal on the right or
- if the right is in a pointer register and left
- is not */
- if ((AOP_TYPE (IC_LEFT (ic)) == AOP_LIT) ||
- (IS_AOP_PREG (right) && !IS_AOP_PREG (left)))
- {
- operand *t = IC_RIGHT (ic);
- IC_RIGHT (ic) = IC_LEFT (ic);
- IC_LEFT (ic) = t;
- }
-
- if (ifx && !AOP_SIZE (result))
- {
- symbol *tlbl;
- /* if they are both bit variables */
- if (AOP_TYPE (left) == AOP_CRY &&
- ((AOP_TYPE (right) == AOP_CRY) || (AOP_TYPE (right) == AOP_LIT)))
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- unsigned long lit = (unsigned long) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
- if (lit == 0L)
- {
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- emitcode ("cpl", "c");
- }
- else if (lit == 1L)
- {
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- }
- else
- {
- emitcode ("clr", "c");
- }
- /* AOP_TYPE(right) == AOP_CRY */
- }
- else
- {
- symbol *lbl = newiTempLabel (NULL);
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- emitcode ("jb", "%s,%05d_DS_", AOP (right)->aopu.aop_dir, (lbl->key + 100));
- emitcode ("cpl", "c");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
- }
- /* if true label then we jump if condition
- supplied is true */
- tlbl = newiTempLabel (NULL);
- if (IC_TRUE (ifx))
- {
- emitcode ("jnc", "%05d_DS_", tlbl->key + 100);
- emitcode ("ljmp", "%05d_DS_", IC_TRUE (ifx)->key + 100);
- }
- else
- {
- emitcode ("jc", "%05d_DS_", tlbl->key + 100);
- emitcode ("ljmp", "%05d_DS_", IC_FALSE (ifx)->key + 100);
- }
- emitcode ("", "%05d_DS_:", tlbl->key + 100 + labelOffset);
- }
- else
- {
-
- /* They're not both bit variables. Is the right a literal? */
- if (AOP_TYPE (right) == AOP_LIT)
- {
-
- lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
- while (size--)
- {
-
- if (size >= 1)
- {
- int l = lit & 0xff;
- int h = (lit >> 8) & 0xff;
- int optimized = 0;
-
- /* Check special cases for integers */
- switch (lit & 0xffff)
- {
- case 0x0000:
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- genSkip (ifx, 'z');
- optimized++;
- break;
- case 0x0001:
- emitcode ("decf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- genSkip (ifx, 'z');
- optimized++;
- break;
- case 0x0100:
- emitcode ("decf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- genSkip (ifx, 'z');
- optimized++;
- break;
- case 0x00ff:
- emitcode ("incf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- genSkip (ifx, 'z');
- optimized++;
- break;
- case 0xff00:
- emitcode ("incf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- genSkip (ifx, 'z');
- optimized++;
- break;
- default:
- if (h == 0)
- {
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("xorlw", "0x%x", l);
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- optimized++;
- genSkip (ifx, 'z');
- }
- else if (l == 0)
- {
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- emitcode ("xorlw", "0x%x", h);
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- optimized++;
- genSkip (ifx, 'z');
- }
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("xorlw", "0x%x", l);
- emitcode ("movlw", "0x%x", h);
- emitSKPZ;
- emitcode ("xorwf", "%s,w", aopGet (AOP (left), offset + 1, FALSE, FALSE));
- optimized++;
- genSkip (ifx, 'z');
- }
-
- }
- if (optimized)
- {
- size--;
- offset += 2;
- lit >>= 16;
-
- continue;
- }
-
- }
-
- switch (lit & 0xff)
- {
- case 1:
- if (IC_TRUE (ifx))
- {
- emitcode ("decf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitSKPNZ;
- emitcode ("goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
- }
- else
- {
- emitcode ("decfsz", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
- }
- break;
- case 0xff:
- if (IC_TRUE (ifx))
- {
- emitcode ("incf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitSKPNZ;
- emitcode ("goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
- }
- else
- {
- emitcode ("incfsz", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
- }
- break;
- default:
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- if (lit)
- emitcode ("xorlw", "0x%x", lit & 0xff);
- genSkip (ifx, 'z');
- }
-
-
- // emitcode("goto","_%05d_DS_",tlbl->key+100+labelOffset);
- //emitcode("","_%05d_DS_:",tlbl->key+100+labelOffset);
- offset++;
- lit >>= 8;
- }
-
- }
- else if (AOP_TYPE (right) == AOP_CRY)
- {
- /* we know the left is not a bit, but that the right is */
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- if (IC_TRUE (ifx))
- emitcode ("btfsc", "(%s >> 3), (%s & 7)",
- AOP (right)->aopu.aop_dir,
- AOP (right)->aopu.aop_dir);
- else
- emitcode ("btfss", "(%s >> 3), (%s & 7)",
- AOP (right)->aopu.aop_dir,
- AOP (right)->aopu.aop_dir);
-
- emitcode ("xorlw", "1");
-
- /* if the two are equal, then W will be 0 and the Z bit is set
- * we could test Z now, or go ahead and check the high order bytes if
- * the variable we're comparing is larger than a byte. */
-
- while (--size)
- emitcode ("iorwf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
-
- if (IC_TRUE (ifx))
- {
- emitSKPNZ;
- emitcode (" goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
- }
- else
- {
- emitSKPZ;
- emitcode (" goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
- }
-
- }
- else
- {
- /* They're both variables that are larger than bits */
- int s = size;
-
- tlbl = newiTempLabel (NULL);
-
- while (size--)
- {
-
- emitcode ("movf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("xorwf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
-
- if (IC_TRUE (ifx))
- {
- if (size)
- {
- emitSKPZ;
- emitcode (" goto", "_%05d_DS_", tlbl->key + 100 + labelOffset);
- }
- else
- {
- emitSKPNZ;
- emitcode (" goto", "_%05d_DS_", IC_TRUE (ifx)->key + 100 + labelOffset);
- }
- }
- else
- {
- emitSKPZ;
- emitcode (" goto", "_%05d_DS_", IC_FALSE (ifx)->key + 100 + labelOffset);
- }
- offset++;
- }
- if (s > 1 && IC_TRUE (ifx))
- emitcode ("", "_%05d_DS_:", tlbl->key + 100 + labelOffset);
- }
- }
- /* mark the icode as generated */
- ifx->generated = 1;
- goto release;
- }
-
- /* if they are both bit variables */
- if (AOP_TYPE (left) == AOP_CRY &&
- ((AOP_TYPE (right) == AOP_CRY) || (AOP_TYPE (right) == AOP_LIT)))
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- unsigned long lit = (unsigned long) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
- if (lit == 0L)
- {
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- emitcode ("cpl", "c");
- }
- else if (lit == 1L)
- {
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- }
- else
- {
- emitcode ("clr", "c");
- }
- /* AOP_TYPE(right) == AOP_CRY */
- }
- else
- {
- symbol *lbl = newiTempLabel (NULL);
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- emitcode ("jb", "%s,%05d_DS_", AOP (right)->aopu.aop_dir, (lbl->key + 100));
- emitcode ("cpl", "c");
- emitcode ("", "%05d_DS_:", (lbl->key + 100));
- }
- /* c = 1 if egal */
- if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
- {
- outBitC (result);
- goto release;
- }
- if (ifx)
- {
- genIfxJump (ifx, "c");
- goto release;
- }
- /* if the result is used in an arithmetic operation
- then put the result in place */
- outBitC (result);
- }
- else
- {
- gencjne (left, right, newiTempLabel (NULL));
- if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
- {
- aopPut (AOP (result), "a", 0);
- goto release;
- }
- if (ifx)
- {
- genIfxJump (ifx, "a");
- goto release;
- }
- /* if the result is used in an arithmetic operation
- then put the result in place */
- if (AOP_TYPE (result) != AOP_CRY)
- outAcc (result);
- /* leave the result in acc */
- }
-
-release:
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* ifxForOp - returns the icode containing the ifx for operand */
-/*-----------------------------------------------------------------*/
-static iCode *
-ifxForOp (operand * op, iCode * ic)
-{
- /* if true symbol then needs to be assigned */
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (IS_TRUE_SYMOP (op))
- return NULL;
-
- /* if this has register type condition and
- the next instruction is ifx with the same operand
- and live to of the operand is upto the ifx only then */
- if (ic->next &&
- ic->next->op == IFX &&
- IC_COND (ic->next)->key == op->key &&
- OP_SYMBOL (op)->liveTo <= ic->next->seq)
- return ic->next;
-
- return NULL;
-}
-/*-----------------------------------------------------------------*/
-/* genAndOp - for && operation */
-/*-----------------------------------------------------------------*/
-static void
-genAndOp (iCode * ic)
-{
- operand *left, *right, *result;
- symbol *tlbl;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* note here that && operations that are in an
- if statement are taken away by backPatchLabels
- only those used in arthmetic operations remain */
- aopOp ((left = IC_LEFT (ic)), ic, FALSE);
- aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
- aopOp ((result = IC_RESULT (ic)), ic, FALSE);
-
- /* if both are bit variables */
- if (AOP_TYPE (left) == AOP_CRY &&
- AOP_TYPE (right) == AOP_CRY)
- {
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- emitcode ("anl", "c,%s", AOP (right)->aopu.aop_dir);
- outBitC (result);
- }
- else
- {
- tlbl = newiTempLabel (NULL);
- toBoolean (left);
- emitcode ("jz", "%05d_DS_", tlbl->key + 100);
- toBoolean (right);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- outBitAcc (result);
- }
-
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-
-/*-----------------------------------------------------------------*/
-/* genOrOp - for || operation */
-/*-----------------------------------------------------------------*/
-/*
- tsd pic port -
- modified this code, but it doesn't appear to ever get called
- */
-
-static void
-genOrOp (iCode * ic)
-{
- operand *left, *right, *result;
- symbol *tlbl;
-
- /* note here that || operations that are in an
- if statement are taken away by backPatchLabels
- only those used in arthmetic operations remain */
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- aopOp ((left = IC_LEFT (ic)), ic, FALSE);
- aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
- aopOp ((result = IC_RESULT (ic)), ic, FALSE);
-
- /* if both are bit variables */
- if (AOP_TYPE (left) == AOP_CRY &&
- AOP_TYPE (right) == AOP_CRY)
- {
- emitcode ("clrc", "");
- emitcode ("btfss", "(%s >> 3), (%s & 7)",
- AOP (left)->aopu.aop_dir,
- AOP (left)->aopu.aop_dir);
- emitcode ("btfsc", "(%s >> 3), (%s & 7)",
- AOP (right)->aopu.aop_dir,
- AOP (right)->aopu.aop_dir);
- emitcode ("setc", "");
-
- }
- else
- {
- tlbl = newiTempLabel (NULL);
- toBoolean (left);
- emitSKPZ;
- emitcode ("goto", "%05d_DS_", tlbl->key + 100 + labelOffset);
- toBoolean (right);
- emitcode ("", "%05d_DS_:", tlbl->key + 100 + labelOffset);
-
- outBitAcc (result);
- }
-
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* isLiteralBit - test if lit == 2^n */
-/*-----------------------------------------------------------------*/
-static int
-isLiteralBit (unsigned long lit)
-{
- unsigned long pw[32] =
- {1L, 2L, 4L, 8L, 16L, 32L, 64L, 128L,
- 0x100L, 0x200L, 0x400L, 0x800L,
- 0x1000L, 0x2000L, 0x4000L, 0x8000L,
- 0x10000L, 0x20000L, 0x40000L, 0x80000L,
- 0x100000L, 0x200000L, 0x400000L, 0x800000L,
- 0x1000000L, 0x2000000L, 0x4000000L, 0x8000000L,
- 0x10000000L, 0x20000000L, 0x40000000L, 0x80000000L};
- int idx;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- for (idx = 0; idx < 32; idx++)
- if (lit == pw[idx])
- return idx + 1;
- return 0;
-}
-
-/*-----------------------------------------------------------------*/
-/* continueIfTrue - */
-/*-----------------------------------------------------------------*/
-static void
-continueIfTrue (iCode * ic)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (IC_TRUE (ic))
- emitcode ("ljmp", "%05d_DS_", IC_TRUE (ic)->key + 100);
- ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* jmpIfTrue - */
-/*-----------------------------------------------------------------*/
-static void
-jumpIfTrue (iCode * ic)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (!IC_TRUE (ic))
- emitcode ("ljmp", "%05d_DS_", IC_FALSE (ic)->key + 100);
- ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* jmpTrueOrFalse - */
-/*-----------------------------------------------------------------*/
-static void
-jmpTrueOrFalse (iCode * ic, symbol * tlbl)
-{
- // ugly but optimized by peephole
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (IC_TRUE (ic))
- {
- symbol *nlbl = newiTempLabel (NULL);
- emitcode ("sjmp", "%05d_DS_", nlbl->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- emitcode ("ljmp", "%05d_DS_", IC_TRUE (ic)->key + 100);
- emitcode ("", "%05d_DS_:", nlbl->key + 100);
- }
- else
- {
- emitcode ("ljmp", "%05d_DS_", IC_FALSE (ic)->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- }
- ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* genAnd - code for and */
-/*-----------------------------------------------------------------*/
-static void
-genAnd (iCode * ic, iCode * ifx)
-{
- operand *left, *right, *result;
- int size, offset = 0;
- unsigned long lit = 0L;
- int bytelit = 0;
- char buffer[10];
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- aopOp ((left = IC_LEFT (ic)), ic, FALSE);
- aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
- aopOp ((result = IC_RESULT (ic)), ic, TRUE);
-
-#ifdef DEBUG_TYPE
- emitcode ("", "; Type res[%d] = l[%d]&r[%d]",
- AOP_TYPE (result),
- AOP_TYPE (left), AOP_TYPE (right));
- emitcode ("", "; Size res[%d] = l[%d]&r[%d]",
- AOP_SIZE (result),
- AOP_SIZE (left), AOP_SIZE (right));
-#endif
-
- /* if left is a literal & right is not then exchange them */
- if ((AOP_TYPE (left) == AOP_LIT && AOP_TYPE (right) != AOP_LIT) ||
- AOP_NEEDSACC (left))
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- /* if result = right then exchange them */
- if (sameRegs (AOP (result), AOP (right)))
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- /* if right is bit then exchange them */
- if (AOP_TYPE (right) == AOP_CRY &&
- AOP_TYPE (left) != AOP_CRY)
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
- if (AOP_TYPE (right) == AOP_LIT)
- lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
-
- size = AOP_SIZE (result);
-
- // if(bit & yy)
- // result = bit & yy;
- if (AOP_TYPE (left) == AOP_CRY)
- {
- // c = bit & literal;
- if (AOP_TYPE (right) == AOP_LIT)
- {
- if (lit & 1)
- {
- if (size && sameRegs (AOP (result), AOP (left)))
- // no change
- goto release;
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- }
- else
- {
- // bit(result) = 0;
- if (size && (AOP_TYPE (result) == AOP_CRY))
- {
- emitcode ("clr", "%s", AOP (result)->aopu.aop_dir);
- goto release;
- }
- if ((AOP_TYPE (result) == AOP_CRY) && ifx)
- {
- jumpIfTrue (ifx);
- goto release;
- }
- emitcode ("clr", "c");
- }
- }
- else
- {
- if (AOP_TYPE (right) == AOP_CRY)
- {
- // c = bit & bit;
- emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- emitcode ("anl", "c,%s", AOP (left)->aopu.aop_dir);
- }
- else
- {
- // c = bit & val;
- MOVA (aopGet (AOP (right), 0, FALSE, FALSE));
- // c = lsb
- emitcode ("rrc", "a");
- emitcode ("anl", "c,%s", AOP (left)->aopu.aop_dir);
- }
- }
- // bit = c
- // val = c
- if (size)
- outBitC (result);
- // if(bit & ...)
- else if ((AOP_TYPE (result) == AOP_CRY) && ifx)
- genIfxJump (ifx, "c");
- goto release;
- }
-
- // if(val & 0xZZ) - size = 0, ifx != FALSE -
- // bit = val & 0xZZ - size = 1, ifx = FALSE -
- if ((AOP_TYPE (right) == AOP_LIT) &&
- (AOP_TYPE (result) == AOP_CRY) &&
- (AOP_TYPE (left) != AOP_CRY))
- {
- int posbit = isLiteralBit (lit);
- /* left & 2^n */
- if (posbit)
- {
- posbit--;
- MOVA (aopGet (AOP (left), posbit >> 3, FALSE, FALSE));
- // bit = left & 2^n
- if (size)
- emitcode ("mov", "c,acc.%d", posbit & 0x07);
- // if(left & 2^n)
- else
- {
- if (ifx)
- {
- sprintf (buffer, "acc.%d", posbit & 0x07);
- genIfxJump (ifx, buffer);
- }
- goto release;
- }
- }
- else
- {
- symbol *tlbl = newiTempLabel (NULL);
- int sizel = AOP_SIZE (left);
- if (size)
- emitcode ("setb", "c");
- while (sizel--)
- {
- if ((bytelit = ((lit >> (offset * 8)) & 0x0FFL)) != 0x0L)
- {
- MOVA (aopGet (AOP (left), offset, FALSE, FALSE));
- // byte == 2^n ?
- if ((posbit = isLiteralBit (bytelit)) != 0)
- emitcode ("jb", "acc.%d,%05d_DS_", (posbit - 1) & 0x07, tlbl->key + 100);
- else
- {
- if (bytelit != 0x0FFL)
- emitcode ("anl", "a,%s",
- aopGet (AOP (right), offset, FALSE, TRUE));
- emitcode ("jnz", "%05d_DS_", tlbl->key + 100);
- }
- }
- offset++;
- }
- // bit = left & literal
- if (size)
- {
- emitcode ("clr", "c");
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- }
- // if(left & literal)
- else
- {
- if (ifx)
- jmpTrueOrFalse (ifx, tlbl);
- goto release;
- }
- }
- outBitC (result);
- goto release;
- }
-
- /* if left is same as result */
- if (sameRegs (AOP (result), AOP (left)))
- {
- for (; size--; offset++, lit >>= 8)
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- switch (lit & 0xff)
- {
- case 0x00:
- /* and'ing with 0 has clears the result */
- emitcode ("clrf", "%s", aopGet (AOP (result), offset, FALSE, FALSE));
- break;
- case 0xff:
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- break;
-
- default:
- {
- int p = my_powof2 ((~lit) & 0xff);
- if (p >= 0)
- {
- /* only one bit is set in the literal, so use a bcf instruction */
- emitcode ("bcf", "%s,%d", aopGet (AOP (left), offset, FALSE, TRUE), p);
- }
- else
- {
- emitcode ("movlw", "0x%x", (lit & 0xff));
- emitcode ("andwf", "%s,f", aopGet (AOP (left), offset, FALSE, TRUE), p);
- }
- }
- }
- }
- else
- {
- if (AOP_TYPE (left) == AOP_ACC)
- emitcode ("iorwf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("iorwf", "%s,f", aopGet (AOP (left), offset, FALSE, FALSE));
-
- }
- }
- }
-
- }
- else
- {
- // left & result in different registers
- if (AOP_TYPE (result) == AOP_CRY)
- {
- // result = bit
- // if(size), result in bit
- // if(!size && ifx), conditional oper: if(left & right)
- symbol *tlbl = newiTempLabel (NULL);
- int sizer = min (AOP_SIZE (left), AOP_SIZE (right));
- if (size)
- emitcode ("setb", "c");
- while (sizer--)
- {
- MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("anl", "a,%s",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("jnz", "%05d_DS_", tlbl->key + 100);
- offset++;
- }
- if (size)
- {
- CLRC;
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- outBitC (result);
- }
- else if (ifx)
- jmpTrueOrFalse (ifx, tlbl);
- }
- else
- {
- for (; (size--); offset++)
- {
- // normal case
- // result = left & right
- if (AOP_TYPE (right) == AOP_LIT)
- {
- int t = (lit >> (offset * 8)) & 0x0FFL;
- switch (t)
- {
- case 0x00:
- emitcode ("clrf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
- break;
- case 0xff:
- emitcode ("movf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
- break;
- default:
- emitcode ("movlw", "0x%x", t);
- emitcode ("andwf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
-
- }
- continue;
- }
-
- if (AOP_TYPE (left) == AOP_ACC)
- emitcode ("andwf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("andwf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- }
- emitcode ("movwf", "%s", aopGet (AOP (result), offset, FALSE, FALSE));
- }
- }
- }
-
-release:
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genOr - code for or */
-/*-----------------------------------------------------------------*/
-static void
-genOr (iCode * ic, iCode * ifx)
-{
- operand *left, *right, *result;
- int size, offset = 0;
- unsigned long lit = 0L;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- aopOp ((left = IC_LEFT (ic)), ic, FALSE);
- aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
- aopOp ((result = IC_RESULT (ic)), ic, TRUE);
-
-
- /* if left is a literal & right is not then exchange them */
- if ((AOP_TYPE (left) == AOP_LIT && AOP_TYPE (right) != AOP_LIT) ||
- AOP_NEEDSACC (left))
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- /* if result = right then exchange them */
- if (sameRegs (AOP (result), AOP (right)))
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- /* if right is bit then exchange them */
- if (AOP_TYPE (right) == AOP_CRY &&
- AOP_TYPE (left) != AOP_CRY)
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- if (AOP_TYPE (right) == AOP_LIT)
- lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
-
- size = AOP_SIZE (result);
-
- // if(bit | yy)
- // xx = bit | yy;
- if (AOP_TYPE (left) == AOP_CRY)
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- // c = bit & literal;
- if (lit)
- {
- // lit != 0 => result = 1
- if (AOP_TYPE (result) == AOP_CRY)
- {
- if (size)
- emitcode ("bsf", "(%s >> 3), (%s & 7)",
- AOP (result)->aopu.aop_dir,
- AOP (result)->aopu.aop_dir);
- else if (ifx)
- continueIfTrue (ifx);
- goto release;
- }
- emitcode (";XXXsetb", "c %s,%d", __FILE__, __LINE__);
- }
- else
- {
- // lit == 0 => result = left
- if (size && sameRegs (AOP (result), AOP (left)))
- goto release;
- emitcode (";XXX mov", "c,%s %s,%d", AOP (left)->aopu.aop_dir, __FILE__, __LINE__);
- }
- }
- else
- {
- if (AOP_TYPE (right) == AOP_CRY)
- {
- if (sameRegs (AOP (result), AOP (left)))
- {
- // c = bit | bit;
- emitcode ("bcf", "(%s >> 3), (%s & 7)",
- AOP (result)->aopu.aop_dir,
- AOP (result)->aopu.aop_dir);
- emitcode ("btfsc", "(%s >> 3), (%s & 7)",
- AOP (right)->aopu.aop_dir,
- AOP (right)->aopu.aop_dir);
- emitcode ("bsf", "(%s >> 3), (%s & 7)",
- AOP (result)->aopu.aop_dir,
- AOP (result)->aopu.aop_dir);
- }
- else
- {
-
- emitcode ("bcf", "(%s >> 3), (%s & 7)",
- AOP (result)->aopu.aop_dir,
- AOP (result)->aopu.aop_dir);
- emitcode ("btfss", "(%s >> 3), (%s & 7)",
- AOP (right)->aopu.aop_dir,
- AOP (right)->aopu.aop_dir);
- emitcode ("btfsc", "(%s >> 3), (%s & 7)",
- AOP (left)->aopu.aop_dir,
- AOP (left)->aopu.aop_dir);
- emitcode ("bsf", "(%s >> 3), (%s & 7)",
- AOP (result)->aopu.aop_dir,
- AOP (result)->aopu.aop_dir);
- }
- }
- else
- {
- // c = bit | val;
- symbol *tlbl = newiTempLabel (NULL);
- emitcode (";XXX ", " %s,%d", __FILE__, __LINE__);
- if (!((AOP_TYPE (result) == AOP_CRY) && ifx))
- emitcode (";XXX setb", "c");
- emitcode (";XXX jb", "%s,%05d_DS_",
- AOP (left)->aopu.aop_dir, tlbl->key + 100);
- toBoolean (right);
- emitcode (";XXX jnz", "%05d_DS_", tlbl->key + 100);
- if ((AOP_TYPE (result) == AOP_CRY) && ifx)
- {
- jmpTrueOrFalse (ifx, tlbl);
- goto release;
- }
- else
- {
- CLRC;
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- }
- }
- }
- // bit = c
- // val = c
- if (size)
- outBitC (result);
- // if(bit | ...)
- else if ((AOP_TYPE (result) == AOP_CRY) && ifx)
- genIfxJump (ifx, "c");
- goto release;
- }
-
- // if(val | 0xZZ) - size = 0, ifx != FALSE -
- // bit = val | 0xZZ - size = 1, ifx = FALSE -
- if ((AOP_TYPE (right) == AOP_LIT) &&
- (AOP_TYPE (result) == AOP_CRY) &&
- (AOP_TYPE (left) != AOP_CRY))
- {
- if (lit)
- {
- emitcode (";XXX ", " %s,%d", __FILE__, __LINE__);
- // result = 1
- if (size)
- emitcode (";XXX setb", "%s", AOP (result)->aopu.aop_dir);
- else
- continueIfTrue (ifx);
- goto release;
- }
- else
- {
- emitcode (";XXX ", " %s,%d", __FILE__, __LINE__);
- // lit = 0, result = boolean(left)
- if (size)
- emitcode (";XXX setb", "c");
- toBoolean (right);
- if (size)
- {
- symbol *tlbl = newiTempLabel (NULL);
- emitcode (";XXX jnz", "%05d_DS_", tlbl->key + 100);
- CLRC;
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- }
- else
- {
- genIfxJump (ifx, "a");
- goto release;
- }
- }
- outBitC (result);
- goto release;
- }
-
- /* if left is same as result */
- if (sameRegs (AOP (result), AOP (left)))
- {
- for (; size--; offset++, lit >>= 8)
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- if ((lit & 0xff) == 0)
- /* or'ing with 0 has no effect */
- continue;
- else
- {
- int p = my_powof2 (lit & 0xff);
- if (p >= 0)
- {
- /* only one bit is set in the literal, so use a bsf instruction */
- emitcode ("bsf", "%s,%d", aopGet (AOP (left), offset, FALSE, TRUE), p);
- }
- else
- {
- emitcode ("movlw", "0x%x", (lit & 0xff));
- emitcode ("iorwf", "%s,f", aopGet (AOP (left), offset, FALSE, TRUE), p);
- }
-
- }
- }
- else
- {
- if (AOP_TYPE (left) == AOP_ACC)
- emitcode ("iorwf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("iorwf", "%s,f", aopGet (AOP (left), offset, FALSE, FALSE));
-
- }
- }
- }
- }
- else
- {
- // left & result in different registers
- if (AOP_TYPE (result) == AOP_CRY)
- {
- // result = bit
- // if(size), result in bit
- // if(!size && ifx), conditional oper: if(left | right)
- symbol *tlbl = newiTempLabel (NULL);
- int sizer = max (AOP_SIZE (left), AOP_SIZE (right));
- emitcode (";XXX ", " %s,%d", __FILE__, __LINE__);
-
- if (size)
- emitcode (";XXX setb", "c");
- while (sizer--)
- {
- MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode (";XXX orl", "a,%s",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode (";XXX jnz", "%05d_DS_", tlbl->key + 100);
- offset++;
- }
- if (size)
- {
- CLRC;
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- outBitC (result);
- }
- else if (ifx)
- jmpTrueOrFalse (ifx, tlbl);
- }
- else
- for (; (size--); offset++)
- {
- // normal case
- // result = left & right
- if (AOP_TYPE (right) == AOP_LIT)
- {
- int t = (lit >> (offset * 8)) & 0x0FFL;
- switch (t)
- {
- case 0x00:
- emitcode ("movf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
- break;
- default:
- emitcode ("movlw", "0x%x", t);
- emitcode ("iorwf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
-
- }
- continue;
- }
-
- // faster than result <- left, anl result,right
- // and better if result is SFR
- if (AOP_TYPE (left) == AOP_ACC)
- emitcode ("iorwf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("iorwf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- }
- emitcode ("movwf", "%s", aopGet (AOP (result), offset, FALSE, FALSE));
- }
- }
-
-release:
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genXor - code for xclusive or */
-/*-----------------------------------------------------------------*/
-static void
-genXor (iCode * ic, iCode * ifx)
-{
- operand *left, *right, *result;
- int size, offset = 0;
- unsigned long lit = 0L;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- aopOp ((left = IC_LEFT (ic)), ic, FALSE);
- aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
- aopOp ((result = IC_RESULT (ic)), ic, TRUE);
-
- /* if left is a literal & right is not ||
- if left needs acc & right does not */
- if ((AOP_TYPE (left) == AOP_LIT && AOP_TYPE (right) != AOP_LIT) ||
- (AOP_NEEDSACC (left) && !AOP_NEEDSACC (right)))
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- /* if result = right then exchange them */
- if (sameRegs (AOP (result), AOP (right)))
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
-
- /* if right is bit then exchange them */
- if (AOP_TYPE (right) == AOP_CRY &&
- AOP_TYPE (left) != AOP_CRY)
- {
- operand *tmp = right;
- right = left;
- left = tmp;
- }
- if (AOP_TYPE (right) == AOP_LIT)
- lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
-
- size = AOP_SIZE (result);
-
- // if(bit ^ yy)
- // xx = bit ^ yy;
- if (AOP_TYPE (left) == AOP_CRY)
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- // c = bit & literal;
- if (lit >> 1)
- {
- // lit>>1 != 0 => result = 1
- if (AOP_TYPE (result) == AOP_CRY)
- {
- if (size)
- emitcode ("setb", "%s", AOP (result)->aopu.aop_dir);
- else if (ifx)
- continueIfTrue (ifx);
- goto release;
- }
- emitcode ("setb", "c");
- }
- else
- {
- // lit == (0 or 1)
- if (lit == 0)
- {
- // lit == 0, result = left
- if (size && sameRegs (AOP (result), AOP (left)))
- goto release;
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- }
- else
- {
- // lit == 1, result = not(left)
- if (size && sameRegs (AOP (result), AOP (left)))
- {
- emitcode ("cpl", "%s", AOP (result)->aopu.aop_dir);
- goto release;
- }
- else
- {
- emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
- emitcode ("cpl", "c");
- }
- }
- }
-
- }
- else
- {
- // right != literal
- symbol *tlbl = newiTempLabel (NULL);
- if (AOP_TYPE (right) == AOP_CRY)
- {
- // c = bit ^ bit;
- emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- }
- else
- {
- int sizer = AOP_SIZE (right);
- // c = bit ^ val
- // if val>>1 != 0, result = 1
- emitcode ("setb", "c");
- while (sizer)
- {
- MOVA (aopGet (AOP (right), sizer - 1, FALSE, FALSE));
- if (sizer == 1)
- // test the msb of the lsb
- emitcode ("anl", "a,#0xfe");
- emitcode ("jnz", "%05d_DS_", tlbl->key + 100);
- sizer--;
- }
- // val = (0,1)
- emitcode ("rrc", "a");
- }
- emitcode ("jnb", "%s,%05d_DS_", AOP (left)->aopu.aop_dir, (tlbl->key + 100));
- emitcode ("cpl", "c");
- emitcode ("", "%05d_DS_:", (tlbl->key + 100));
- }
- // bit = c
- // val = c
- if (size)
- outBitC (result);
- // if(bit | ...)
- else if ((AOP_TYPE (result) == AOP_CRY) && ifx)
- genIfxJump (ifx, "c");
- goto release;
- }
-
- if (sameRegs (AOP (result), AOP (left)))
- {
- /* if left is same as result */
- for (; size--; offset++)
- {
- if (AOP_TYPE (right) == AOP_LIT)
- {
- if (((lit >> (offset * 8)) & 0x0FFL) == 0x00L)
- continue;
- else if (IS_AOP_PREG (left))
- {
- MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
- }
- else
- emitcode ("xrl", "%s,%s",
- aopGet (AOP (left), offset, FALSE, TRUE),
- aopGet (AOP (right), offset, FALSE, FALSE));
- }
- else
- {
- if (AOP_TYPE (left) == AOP_ACC)
- emitcode ("xrl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE));
- else
- {
- MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
- if (IS_AOP_PREG (left))
- {
- emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
- }
- else
- emitcode ("xrl", "%s,a",
- aopGet (AOP (left), offset, FALSE, TRUE));
- }
- }
- }
- }
- else
- {
- // left & result in different registers
- if (AOP_TYPE (result) == AOP_CRY)
- {
- // result = bit
- // if(size), result in bit
- // if(!size && ifx), conditional oper: if(left ^ right)
- symbol *tlbl = newiTempLabel (NULL);
- int sizer = max (AOP_SIZE (left), AOP_SIZE (right));
- if (size)
- emitcode ("setb", "c");
- while (sizer--)
- {
- if ((AOP_TYPE (right) == AOP_LIT) &&
- (((lit >> (offset * 8)) & 0x0FFL) == 0x00L))
- {
- MOVA (aopGet (AOP (left), offset, FALSE, FALSE));
- }
- else
- {
- MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("xrl", "a,%s",
- aopGet (AOP (left), offset, FALSE, FALSE));
- }
- emitcode ("jnz", "%05d_DS_", tlbl->key + 100);
- offset++;
- }
- if (size)
- {
- CLRC;
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- outBitC (result);
- }
- else if (ifx)
- jmpTrueOrFalse (ifx, tlbl);
- }
- else
- for (; (size--); offset++)
- {
- // normal case
- // result = left & right
- if (AOP_TYPE (right) == AOP_LIT)
- {
- int t = (lit >> (offset * 8)) & 0x0FFL;
- switch (t)
- {
- case 0x00:
- emitcode ("movf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
- break;
- case 0xff:
- emitcode ("comf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
- break;
- default:
- emitcode ("movlw", "0x%x", t);
- emitcode ("xorwf", "%s,w",
- aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset, FALSE, FALSE));
-
- }
- continue;
- }
-
- // faster than result <- left, anl result,right
- // and better if result is SFR
- if (AOP_TYPE (left) == AOP_ACC)
- emitcode ("xorwf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("xorwf", "%s,w", aopGet (AOP (left), offset, FALSE, FALSE));
- }
- if (AOP_TYPE (result) != AOP_ACC)
- emitcode ("movwf", "%s", aopGet (AOP (result), offset, FALSE, FALSE));
- }
- }
-
-release:
- freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genInline - write the inline code out */
-/*-----------------------------------------------------------------*/
-static void
-genInline (iCode * ic)
-{
- char buffer[MAX_INLINEASM];
- char *bp = buffer;
- char *bp1 = buffer;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- _G.inLine += (!options.asmpeep);
- strcpy (buffer, IC_INLINE (ic));
-
- /* emit each line as a code */
- while (*bp)
- {
- if (*bp == '\n')
- {
- *bp++ = '\0';
- emitcode (bp1, "");
- bp1 = bp;
- }
- else
- {
- if (*bp == ':')
- {
- bp++;
- *bp = '\0';
- bp++;
- emitcode (bp1, "");
- bp1 = bp;
- }
- else
- bp++;
- }
- }
- if (bp1 != bp)
- emitcode (bp1, "");
- /* emitcode("",buffer); */
- _G.inLine -= (!options.asmpeep);
-}
-
-/*-----------------------------------------------------------------*/
-/* genRRC - rotate right with carry */
-/*-----------------------------------------------------------------*/
-static void
-genRRC (iCode * ic)
-{
- operand *left, *result;
- int size, offset = 0;
- char *l;
-
- /* rotate right with carry */
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- /* move it to the result */
- size = AOP_SIZE (result);
- offset = size - 1;
- CLRC;
- while (size--)
- {
- l = aopGet (AOP (left), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("rrc", "a");
- if (AOP_SIZE (result) > 1)
- aopPut (AOP (result), "a", offset--);
- }
- /* now we need to put the carry into the
- highest order byte of the result */
- if (AOP_SIZE (result) > 1)
- {
- l = aopGet (AOP (result), AOP_SIZE (result) - 1, FALSE, FALSE);
- MOVA (l);
- }
- emitcode ("mov", "acc.7,c");
- aopPut (AOP (result), "a", AOP_SIZE (result) - 1);
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genRLC - generate code for rotate left with carry */
-/*-----------------------------------------------------------------*/
-static void
-genRLC (iCode * ic)
-{
- operand *left, *result;
- int size, offset = 0;
- char *l;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* rotate right with carry */
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- /* move it to the result */
- size = AOP_SIZE (result);
- offset = 0;
- if (size--)
- {
- l = aopGet (AOP (left), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("add", "a,acc");
- if (AOP_SIZE (result) > 1)
- aopPut (AOP (result), "a", offset++);
- while (size--)
- {
- l = aopGet (AOP (left), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("rlc", "a");
- if (AOP_SIZE (result) > 1)
- aopPut (AOP (result), "a", offset++);
- }
- }
- /* now we need to put the carry into the
- highest order byte of the result */
- if (AOP_SIZE (result) > 1)
- {
- l = aopGet (AOP (result), 0, FALSE, FALSE);
- MOVA (l);
- }
- emitcode ("mov", "acc.0,c");
- aopPut (AOP (result), "a", 0);
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genGetHbit - generates code get highest order bit */
-/*-----------------------------------------------------------------*/
-static void
-genGetHbit (iCode * ic)
-{
- operand *left, *result;
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* get the highest order byte into a */
- MOVA (aopGet (AOP (left), AOP_SIZE (left) - 1, FALSE, FALSE));
- if (AOP_TYPE (result) == AOP_CRY)
- {
- emitcode ("rlc", "a");
- outBitC (result);
- }
- else
- {
- emitcode ("rl", "a");
- emitcode ("anl", "a,#0x01");
- outAcc (result);
- }
-
-
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* AccRol - rotate left accumulator by known count */
-/*-----------------------------------------------------------------*/
-static void
-AccRol (int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- shCount &= 0x0007; // shCount : 0..7
-
- switch (shCount)
- {
- case 0:
- break;
- case 1:
- emitcode ("rl", "a");
- break;
- case 2:
- emitcode ("rl", "a");
- emitcode ("rl", "a");
- break;
- case 3:
- emitcode ("swap", "a");
- emitcode ("rr", "a");
- break;
- case 4:
- emitcode ("swap", "a");
- break;
- case 5:
- emitcode ("swap", "a");
- emitcode ("rl", "a");
- break;
- case 6:
- emitcode ("rr", "a");
- emitcode ("rr", "a");
- break;
- case 7:
- emitcode ("rr", "a");
- break;
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* AccLsh - left shift accumulator by known count */
-/*-----------------------------------------------------------------*/
-static void
-AccLsh (int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (shCount != 0)
- {
- if (shCount == 1)
- emitcode ("add", "a,acc");
- else if (shCount == 2)
- {
- emitcode ("add", "a,acc");
- emitcode ("add", "a,acc");
- }
- else
- {
- /* rotate left accumulator */
- AccRol (shCount);
- /* and kill the lower order bits */
- emitcode ("anl", "a,#0x%02x", SLMask[shCount]);
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* AccRsh - right shift accumulator by known count */
-/*-----------------------------------------------------------------*/
-static void
-AccRsh (int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (shCount != 0)
- {
- if (shCount == 1)
- {
- CLRC;
- emitcode ("rrc", "a");
- }
- else
- {
- /* rotate right accumulator */
- AccRol (8 - shCount);
- /* and kill the higher order bits */
- emitcode ("anl", "a,#0x%02x", SRMask[shCount]);
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* AccSRsh - signed right shift accumulator by known count */
-/*-----------------------------------------------------------------*/
-static void
-AccSRsh (int shCount)
-{
- symbol *tlbl;
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (shCount != 0)
- {
- if (shCount == 1)
- {
- emitcode ("mov", "c,acc.7");
- emitcode ("rrc", "a");
- }
- else if (shCount == 2)
- {
- emitcode ("mov", "c,acc.7");
- emitcode ("rrc", "a");
- emitcode ("mov", "c,acc.7");
- emitcode ("rrc", "a");
- }
- else
- {
- tlbl = newiTempLabel (NULL);
- /* rotate right accumulator */
- AccRol (8 - shCount);
- /* and kill the higher order bits */
- emitcode ("anl", "a,#0x%02x", SRMask[shCount]);
- emitcode ("jnb", "acc.%d,%05d_DS_", 7 - shCount, tlbl->key + 100);
- emitcode ("orl", "a,#0x%02x",
- (unsigned char) ~SRMask[shCount]);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftR1Left2Result - shift right one byte from left to result */
-/*-----------------------------------------------------------------*/
-static void
-shiftR1Left2Result (operand * left, int offl,
- operand * result, int offr,
- int shCount, int sign)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- MOVA (aopGet (AOP (left), offl, FALSE, FALSE));
- /* shift right accumulator */
- if (sign)
- AccSRsh (shCount);
- else
- AccRsh (shCount);
- aopPut (AOP (result), "a", offr);
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftL1Left2Result - shift left one byte from left to result */
-/*-----------------------------------------------------------------*/
-static void
-shiftL1Left2Result (operand * left, int offl,
- operand * result, int offr, int shCount)
-{
- char *l;
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- l = aopGet (AOP (left), offl, FALSE, FALSE);
- MOVA (l);
- /* shift left accumulator */
- AccLsh (shCount);
- aopPut (AOP (result), "a", offr);
-}
-
-/*-----------------------------------------------------------------*/
-/* movLeft2Result - move byte from left to result */
-/*-----------------------------------------------------------------*/
-static void
-movLeft2Result (operand * left, int offl,
- operand * result, int offr, int sign)
-{
- char *l;
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (!sameRegs (AOP (left), AOP (result)) || (offl != offr))
- {
- l = aopGet (AOP (left), offl, FALSE, FALSE);
-
- if (*l == '@' && (IS_AOP_PREG (result)))
- {
- emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offr);
- }
- else
- {
- if (!sign)
- aopPut (AOP (result), l, offr);
- else
- {
- /* MSB sign in acc.7 ! */
- if (getDataSize (left) == offl + 1)
- {
- emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offr);
- }
- }
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* AccAXRrl1 - right rotate c->a:x->c by 1 */
-/*-----------------------------------------------------------------*/
-static void
-AccAXRrl1 (char *x)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- emitcode ("rrc", "a");
- emitcode ("xch", "a,%s", x);
- emitcode ("rrc", "a");
- emitcode ("xch", "a,%s", x);
-}
-
-/*-----------------------------------------------------------------*/
-/* AccAXLrl1 - left rotate c<-a:x<-c by 1 */
-/*-----------------------------------------------------------------*/
-static void
-AccAXLrl1 (char *x)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- emitcode ("xch", "a,%s", x);
- emitcode ("rlc", "a");
- emitcode ("xch", "a,%s", x);
- emitcode ("rlc", "a");
-}
-
-/*-----------------------------------------------------------------*/
-/* AccAXLsh1 - left shift a:x<-0 by 1 */
-/*-----------------------------------------------------------------*/
-static void
-AccAXLsh1 (char *x)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- emitcode ("xch", "a,%s", x);
- emitcode ("add", "a,acc");
- emitcode ("xch", "a,%s", x);
- emitcode ("rlc", "a");
-}
-
-/*-----------------------------------------------------------------*/
-/* AccAXLsh - left shift a:x by known count (0..7) */
-/*-----------------------------------------------------------------*/
-static void
-AccAXLsh (char *x, int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- switch (shCount)
- {
- case 0:
- break;
- case 1:
- AccAXLsh1 (x);
- break;
- case 2:
- AccAXLsh1 (x);
- AccAXLsh1 (x);
- break;
- case 3:
- case 4:
- case 5: // AAAAABBB:CCCCCDDD
-
- AccRol (shCount); // BBBAAAAA:CCCCCDDD
-
- emitcode ("anl", "a,#0x%02x",
- SLMask[shCount]); // BBB00000:CCCCCDDD
-
- emitcode ("xch", "a,%s", x); // CCCCCDDD:BBB00000
-
- AccRol (shCount); // DDDCCCCC:BBB00000
-
- emitcode ("xch", "a,%s", x); // BBB00000:DDDCCCCC
-
- emitcode ("xrl", "a,%s", x); // (BBB^DDD)CCCCC:DDDCCCCC
-
- emitcode ("xch", "a,%s", x); // DDDCCCCC:(BBB^DDD)CCCCC
-
- emitcode ("anl", "a,#0x%02x",
- SLMask[shCount]); // DDD00000:(BBB^DDD)CCCCC
-
- emitcode ("xch", "a,%s", x); // (BBB^DDD)CCCCC:DDD00000
-
- emitcode ("xrl", "a,%s", x); // BBBCCCCC:DDD00000
-
- break;
- case 6: // AAAAAABB:CCCCCCDD
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000000BB:CCCCCCDD
-
- emitcode ("mov", "c,acc.0"); // c = B
-
- emitcode ("xch", "a,%s", x); // CCCCCCDD:000000BB
-
- AccAXRrl1 (x); // BCCCCCCD:D000000B
-
- AccAXRrl1 (x); // BBCCCCCC:DD000000
-
- break;
- case 7: // a:x <<= 7
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 0000000B:CCCCCCCD
-
- emitcode ("mov", "c,acc.0"); // c = B
-
- emitcode ("xch", "a,%s", x); // CCCCCCCD:0000000B
-
- AccAXRrl1 (x); // BCCCCCCC:D0000000
-
- break;
- default:
- break;
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* AccAXRsh - right shift a:x known count (0..7) */
-/*-----------------------------------------------------------------*/
-static void
-AccAXRsh (char *x, int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- switch (shCount)
- {
- case 0:
- break;
- case 1:
- CLRC;
- AccAXRrl1 (x); // 0->a:x
-
- break;
- case 2:
- CLRC;
- AccAXRrl1 (x); // 0->a:x
-
- CLRC;
- AccAXRrl1 (x); // 0->a:x
-
- break;
- case 3:
- case 4:
- case 5: // AAAAABBB:CCCCCDDD = a:x
-
- AccRol (8 - shCount); // BBBAAAAA:DDDCCCCC
-
- emitcode ("xch", "a,%s", x); // CCCCCDDD:BBBAAAAA
-
- AccRol (8 - shCount); // DDDCCCCC:BBBAAAAA
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000CCCCC:BBBAAAAA
-
- emitcode ("xrl", "a,%s", x); // BBB(CCCCC^AAAAA):BBBAAAAA
-
- emitcode ("xch", "a,%s", x); // BBBAAAAA:BBB(CCCCC^AAAAA)
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000AAAAA:BBB(CCCCC^AAAAA)
-
- emitcode ("xch", "a,%s", x); // BBB(CCCCC^AAAAA):000AAAAA
-
- emitcode ("xrl", "a,%s", x); // BBBCCCCC:000AAAAA
-
- emitcode ("xch", "a,%s", x); // 000AAAAA:BBBCCCCC
-
- break;
- case 6: // AABBBBBB:CCDDDDDD
-
- emitcode ("mov", "c,acc.7");
- AccAXLrl1 (x); // ABBBBBBC:CDDDDDDA
-
- AccAXLrl1 (x); // BBBBBBCC:DDDDDDAA
-
- emitcode ("xch", "a,%s", x); // DDDDDDAA:BBBBBBCC
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000000AA:BBBBBBCC
-
- break;
- case 7: // ABBBBBBB:CDDDDDDD
-
- emitcode ("mov", "c,acc.7"); // c = A
-
- AccAXLrl1 (x); // BBBBBBBC:DDDDDDDA
-
- emitcode ("xch", "a,%s", x); // DDDDDDDA:BBBBBBCC
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 0000000A:BBBBBBBC
-
- break;
- default:
- break;
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* AccAXRshS - right shift signed a:x known count (0..7) */
-/*-----------------------------------------------------------------*/
-static void
-AccAXRshS (char *x, int shCount)
-{
- symbol *tlbl;
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- switch (shCount)
- {
- case 0:
- break;
- case 1:
- emitcode ("mov", "c,acc.7");
- AccAXRrl1 (x); // s->a:x
-
- break;
- case 2:
- emitcode ("mov", "c,acc.7");
- AccAXRrl1 (x); // s->a:x
-
- emitcode ("mov", "c,acc.7");
- AccAXRrl1 (x); // s->a:x
-
- break;
- case 3:
- case 4:
- case 5: // AAAAABBB:CCCCCDDD = a:x
-
- tlbl = newiTempLabel (NULL);
- AccRol (8 - shCount); // BBBAAAAA:CCCCCDDD
-
- emitcode ("xch", "a,%s", x); // CCCCCDDD:BBBAAAAA
-
- AccRol (8 - shCount); // DDDCCCCC:BBBAAAAA
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000CCCCC:BBBAAAAA
-
- emitcode ("xrl", "a,%s", x); // BBB(CCCCC^AAAAA):BBBAAAAA
-
- emitcode ("xch", "a,%s", x); // BBBAAAAA:BBB(CCCCC^AAAAA)
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000AAAAA:BBB(CCCCC^AAAAA)
-
- emitcode ("xch", "a,%s", x); // BBB(CCCCC^AAAAA):000AAAAA
-
- emitcode ("xrl", "a,%s", x); // BBBCCCCC:000AAAAA
-
- emitcode ("xch", "a,%s", x); // 000SAAAA:BBBCCCCC
-
- emitcode ("jnb", "acc.%d,%05d_DS_", 7 - shCount, tlbl->key + 100);
- emitcode ("orl", "a,#0x%02x",
- (unsigned char) ~SRMask[shCount]); // 111AAAAA:BBBCCCCC
-
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- break; // SSSSAAAA:BBBCCCCC
-
- case 6: // AABBBBBB:CCDDDDDD
-
- tlbl = newiTempLabel (NULL);
- emitcode ("mov", "c,acc.7");
- AccAXLrl1 (x); // ABBBBBBC:CDDDDDDA
-
- AccAXLrl1 (x); // BBBBBBCC:DDDDDDAA
-
- emitcode ("xch", "a,%s", x); // DDDDDDAA:BBBBBBCC
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 000000AA:BBBBBBCC
-
- emitcode ("jnb", "acc.%d,%05d_DS_", 7 - shCount, tlbl->key + 100);
- emitcode ("orl", "a,#0x%02x",
- (unsigned char) ~SRMask[shCount]); // 111111AA:BBBBBBCC
-
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- break;
- case 7: // ABBBBBBB:CDDDDDDD
-
- tlbl = newiTempLabel (NULL);
- emitcode ("mov", "c,acc.7"); // c = A
-
- AccAXLrl1 (x); // BBBBBBBC:DDDDDDDA
-
- emitcode ("xch", "a,%s", x); // DDDDDDDA:BBBBBBCC
-
- emitcode ("anl", "a,#0x%02x",
- SRMask[shCount]); // 0000000A:BBBBBBBC
-
- emitcode ("jnb", "acc.%d,%05d_DS_", 7 - shCount, tlbl->key + 100);
- emitcode ("orl", "a,#0x%02x",
- (unsigned char) ~SRMask[shCount]); // 1111111A:BBBBBBBC
-
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- break;
- default:
- break;
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftL2Left2Result - shift left two bytes from left to result */
-/*-----------------------------------------------------------------*/
-static void
-shiftL2Left2Result (operand * left, int offl,
- operand * result, int offr, int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (sameRegs (AOP (result), AOP (left)) &&
- ((offl + MSB16) == offr))
- {
- /* don't crash result[offr] */
- MOVA (aopGet (AOP (left), offl, FALSE, FALSE));
- emitcode ("xch", "a,%s", aopGet (AOP (left), offl + MSB16, FALSE, FALSE));
- }
- else
- {
- movLeft2Result (left, offl, result, offr, 0);
- MOVA (aopGet (AOP (left), offl + MSB16, FALSE, FALSE));
- }
- /* ax << shCount (x = lsb(result)) */
- AccAXLsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount);
- aopPut (AOP (result), "a", offr + MSB16);
-}
-
-
-/*-----------------------------------------------------------------*/
-/* shiftR2Left2Result - shift right two bytes from left to result */
-/*-----------------------------------------------------------------*/
-static void
-shiftR2Left2Result (operand * left, int offl,
- operand * result, int offr,
- int shCount, int sign)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (sameRegs (AOP (result), AOP (left)) &&
- ((offl + MSB16) == offr))
- {
- /* don't crash result[offr] */
- MOVA (aopGet (AOP (left), offl, FALSE, FALSE));
- emitcode ("xch", "a,%s", aopGet (AOP (left), offl + MSB16, FALSE, FALSE));
- }
- else
- {
- movLeft2Result (left, offl, result, offr, 0);
- MOVA (aopGet (AOP (left), offl + MSB16, FALSE, FALSE));
- }
- /* a:x >> shCount (x = lsb(result)) */
- if (sign)
- AccAXRshS (aopGet (AOP (result), offr, FALSE, FALSE), shCount);
- else
- AccAXRsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount);
- if (getDataSize (result) > 1)
- aopPut (AOP (result), "a", offr + MSB16);
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftLLeftOrResult - shift left one byte from left, or to result */
-/*-----------------------------------------------------------------*/
-static void
-shiftLLeftOrResult (operand * left, int offl,
- operand * result, int offr, int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- MOVA (aopGet (AOP (left), offl, FALSE, FALSE));
- /* shift left accumulator */
- AccLsh (shCount);
- /* or with result */
- emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE));
- /* back to result */
- aopPut (AOP (result), "a", offr);
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftRLeftOrResult - shift right one byte from left,or to result */
-/*-----------------------------------------------------------------*/
-static void
-shiftRLeftOrResult (operand * left, int offl,
- operand * result, int offr, int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- MOVA (aopGet (AOP (left), offl, FALSE, FALSE));
- /* shift right accumulator */
- AccRsh (shCount);
- /* or with result */
- emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE));
- /* back to result */
- aopPut (AOP (result), "a", offr);
-}
-
-/*-----------------------------------------------------------------*/
-/* genlshOne - left shift a one byte quantity by known count */
-/*-----------------------------------------------------------------*/
-static void
-genlshOne (operand * result, operand * left, int shCount)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- shiftL1Left2Result (left, LSB, result, LSB, shCount);
-}
-
-/*-----------------------------------------------------------------*/
-/* genlshTwo - left shift two bytes by known amount != 0 */
-/*-----------------------------------------------------------------*/
-static void
-genlshTwo (operand * result, operand * left, int shCount)
-{
- int size;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- size = getDataSize (result);
-
- /* if shCount >= 8 */
- if (shCount >= 8)
- {
- shCount -= 8;
-
- if (size > 1)
- {
- if (shCount)
- shiftL1Left2Result (left, LSB, result, MSB16, shCount);
- else
- movLeft2Result (left, LSB, result, MSB16, 0);
- }
- aopPut (AOP (result), zero, LSB);
- }
-
- /* 1 <= shCount <= 7 */
- else
- {
- if (size == 1)
- shiftL1Left2Result (left, LSB, result, LSB, shCount);
- else
- shiftL2Left2Result (left, LSB, result, LSB, shCount);
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftLLong - shift left one long from left to result */
-/* offl = LSB or MSB16 */
-/*-----------------------------------------------------------------*/
-static void
-shiftLLong (operand * left, operand * result, int offr)
-{
- char *l;
- int size = AOP_SIZE (result);
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (size >= LSB + offr)
- {
- l = aopGet (AOP (left), LSB, FALSE, FALSE);
- MOVA (l);
- emitcode ("add", "a,acc");
- if (sameRegs (AOP (left), AOP (result)) &&
- size >= MSB16 + offr && offr != LSB)
- emitcode ("xch", "a,%s",
- aopGet (AOP (left), LSB + offr, FALSE, FALSE));
- else
- aopPut (AOP (result), "a", LSB + offr);
- }
-
- if (size >= MSB16 + offr)
- {
- if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB16 + offr && offr != LSB))
- {
- l = aopGet (AOP (left), MSB16, FALSE, FALSE);
- MOVA (l);
- }
- emitcode ("rlc", "a");
- if (sameRegs (AOP (left), AOP (result)) &&
- size >= MSB24 + offr && offr != LSB)
- emitcode ("xch", "a,%s",
- aopGet (AOP (left), MSB16 + offr, FALSE, FALSE));
- else
- aopPut (AOP (result), "a", MSB16 + offr);
- }
-
- if (size >= MSB24 + offr)
- {
- if (!(sameRegs (AOP (left), AOP (left)) && size >= MSB24 + offr && offr != LSB))
- {
- l = aopGet (AOP (left), MSB24, FALSE, FALSE);
- MOVA (l);
- }
- emitcode ("rlc", "a");
- if (sameRegs (AOP (left), AOP (result)) &&
- size >= MSB32 + offr && offr != LSB)
- emitcode ("xch", "a,%s",
- aopGet (AOP (left), MSB24 + offr, FALSE, FALSE));
- else
- aopPut (AOP (result), "a", MSB24 + offr);
- }
-
- if (size > MSB32 + offr)
- {
- if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB32 + offr && offr != LSB))
- {
- l = aopGet (AOP (left), MSB32, FALSE, FALSE);
- MOVA (l);
- }
- emitcode ("rlc", "a");
- aopPut (AOP (result), "a", MSB32 + offr);
- }
- if (offr != LSB)
- aopPut (AOP (result), zero, LSB);
-}
-
-/*-----------------------------------------------------------------*/
-/* genlshFour - shift four byte by a known amount != 0 */
-/*-----------------------------------------------------------------*/
-static void
-genlshFour (operand * result, operand * left, int shCount)
-{
- int size;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- size = AOP_SIZE (result);
-
- /* if shifting more that 3 bytes */
- if (shCount >= 24)
- {
- shCount -= 24;
- if (shCount)
- /* lowest order of left goes to the highest
- order of the destination */
- shiftL1Left2Result (left, LSB, result, MSB32, shCount);
- else
- movLeft2Result (left, LSB, result, MSB32, 0);
- aopPut (AOP (result), zero, LSB);
- aopPut (AOP (result), zero, MSB16);
- aopPut (AOP (result), zero, MSB32);
- return;
- }
-
- /* more than two bytes */
- else if (shCount >= 16)
- {
- /* lower order two bytes goes to higher order two bytes */
- shCount -= 16;
- /* if some more remaining */
- if (shCount)
- shiftL2Left2Result (left, LSB, result, MSB24, shCount);
- else
- {
- movLeft2Result (left, MSB16, result, MSB32, 0);
- movLeft2Result (left, LSB, result, MSB24, 0);
- }
- aopPut (AOP (result), zero, MSB16);
- aopPut (AOP (result), zero, LSB);
- return;
- }
-
- /* if more than 1 byte */
- else if (shCount >= 8)
- {
- /* lower order three bytes goes to higher order three bytes */
- shCount -= 8;
- if (size == 2)
- {
- if (shCount)
- shiftL1Left2Result (left, LSB, result, MSB16, shCount);
- else
- movLeft2Result (left, LSB, result, MSB16, 0);
- }
- else
- { /* size = 4 */
- if (shCount == 0)
- {
- movLeft2Result (left, MSB24, result, MSB32, 0);
- movLeft2Result (left, MSB16, result, MSB24, 0);
- movLeft2Result (left, LSB, result, MSB16, 0);
- aopPut (AOP (result), zero, LSB);
- }
- else if (shCount == 1)
- shiftLLong (left, result, MSB16);
- else
- {
- shiftL2Left2Result (left, MSB16, result, MSB24, shCount);
- shiftL1Left2Result (left, LSB, result, MSB16, shCount);
- shiftRLeftOrResult (left, LSB, result, MSB24, 8 - shCount);
- aopPut (AOP (result), zero, LSB);
- }
- }
- }
-
- /* 1 <= shCount <= 7 */
- else if (shCount <= 2)
- {
- shiftLLong (left, result, LSB);
- if (shCount == 2)
- shiftLLong (result, result, LSB);
- }
- /* 3 <= shCount <= 7, optimize */
- else
- {
- shiftL2Left2Result (left, MSB24, result, MSB24, shCount);
- shiftRLeftOrResult (left, MSB16, result, MSB24, 8 - shCount);
- shiftL2Left2Result (left, LSB, result, LSB, shCount);
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* genLeftShiftLiteral - left shifting by known count */
-/*-----------------------------------------------------------------*/
-static void
-genLeftShiftLiteral (operand * left,
- operand * right,
- operand * result,
- iCode * ic)
-{
- int shCount = (int) floatFromVal (AOP (right)->aopu.aop_lit);
- int size;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- freeAsmop (right, NULL, ic, TRUE);
-
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- size = getSize (operandType (result));
-
-#if VIEW_SIZE
- emitcode ("; shift left ", "result %d, left %d", size,
- AOP_SIZE (left));
-#endif
-
- /* I suppose that the left size >= result size */
- if (shCount == 0)
- {
- while (size--)
- {
- movLeft2Result (left, size, result, size, 0);
- }
- }
-
- else if (shCount >= (size * 8))
- while (size--)
- aopPut (AOP (result), zero, size);
- else
- {
- switch (size)
- {
- case 1:
- genlshOne (result, left, shCount);
- break;
-
- case 2:
- case 3:
- genlshTwo (result, left, shCount);
- break;
-
- case 4:
- genlshFour (result, left, shCount);
- break;
- }
- }
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genLeftShift - generates code for left shifting */
-/*-----------------------------------------------------------------*/
-static void
-genLeftShift (iCode * ic)
-{
- operand *left, *right, *result;
- int size, offset;
- char *l;
- symbol *tlbl, *tlbl1;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- right = IC_RIGHT (ic);
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
-
- aopOp (right, ic, FALSE);
-
- /* if the shift count is known then do it
- as efficiently as possible */
- if (AOP_TYPE (right) == AOP_LIT)
- {
- genLeftShiftLiteral (left, right, result, ic);
- return;
- }
-
- /* shift count is unknown then we have to form
- a loop get the loop count in B : Note: we take
- only the lower order byte since shifting
- more that 32 bits make no sense anyway, ( the
- largest size of an object can be only 32 bits ) */
-
- emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- emitcode ("inc", "b");
- freeAsmop (right, NULL, ic, TRUE);
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- /* now move the left to the result if they are not the
- same */
- if (!sameRegs (AOP (left), AOP (result)) &&
- AOP_SIZE (result) > 1)
- {
-
- size = AOP_SIZE (result);
- offset = 0;
- while (size--)
- {
- l = aopGet (AOP (left), offset, FALSE, TRUE);
- if (*l == '@' && (IS_AOP_PREG (result)))
- {
-
- emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offset);
- }
- else
- aopPut (AOP (result), l, offset);
- offset++;
- }
- }
-
- tlbl = newiTempLabel (NULL);
- size = AOP_SIZE (result);
- offset = 0;
- tlbl1 = newiTempLabel (NULL);
-
- /* if it is only one byte then */
- if (size == 1)
- {
- symbol *tlbl1 = newiTempLabel (NULL);
-
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
- emitcode ("sjmp", "%05d_DS_", tlbl1->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- emitcode ("add", "a,acc");
- emitcode ("", "%05d_DS_:", tlbl1->key + 100);
- emitcode ("djnz", "b,%05d_DS_", tlbl->key + 100);
- aopPut (AOP (result), "a", 0);
- goto release;
- }
-
- reAdjustPreg (AOP (result));
-
- emitcode ("sjmp", "%05d_DS_", tlbl1->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- l = aopGet (AOP (result), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("add", "a,acc");
- aopPut (AOP (result), "a", offset++);
- while (--size)
- {
- l = aopGet (AOP (result), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("rlc", "a");
- aopPut (AOP (result), "a", offset++);
- }
- reAdjustPreg (AOP (result));
-
- emitcode ("", "%05d_DS_:", tlbl1->key + 100);
- emitcode ("djnz", "b,%05d_DS_", tlbl->key + 100);
-release:
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genrshOne - right shift a one byte quantity by known count */
-/*-----------------------------------------------------------------*/
-static void
-genrshOne (operand * result, operand * left,
- int shCount, int sign)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- shiftR1Left2Result (left, LSB, result, LSB, shCount, sign);
-}
-
-/*-----------------------------------------------------------------*/
-/* genrshTwo - right shift two bytes by known amount != 0 */
-/*-----------------------------------------------------------------*/
-static void
-genrshTwo (operand * result, operand * left,
- int shCount, int sign)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* if shCount >= 8 */
- if (shCount >= 8)
- {
- shCount -= 8;
- if (shCount)
- shiftR1Left2Result (left, MSB16, result, LSB,
- shCount, sign);
- else
- movLeft2Result (left, MSB16, result, LSB, sign);
- addSign (result, MSB16, sign);
- }
-
- /* 1 <= shCount <= 7 */
- else
- shiftR2Left2Result (left, LSB, result, LSB, shCount, sign);
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftRLong - shift right one long from left to result */
-/* offl = LSB or MSB16 */
-/*-----------------------------------------------------------------*/
-static void
-shiftRLong (operand * left, int offl,
- operand * result, int sign)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (!sign)
- emitcode ("clr", "c");
- MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE));
- if (sign)
- emitcode ("mov", "c,acc.7");
- emitcode ("rrc", "a");
- aopPut (AOP (result), "a", MSB32 - offl);
- if (offl == MSB16)
- /* add sign of "a" */
- addSign (result, MSB32, sign);
-
- MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE));
- emitcode ("rrc", "a");
- aopPut (AOP (result), "a", MSB24 - offl);
-
- MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE));
- emitcode ("rrc", "a");
- aopPut (AOP (result), "a", MSB16 - offl);
-
- if (offl == LSB)
- {
- MOVA (aopGet (AOP (left), LSB, FALSE, FALSE));
- emitcode ("rrc", "a");
- aopPut (AOP (result), "a", LSB);
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* genrshFour - shift four byte by a known amount != 0 */
-/*-----------------------------------------------------------------*/
-static void
-genrshFour (operand * result, operand * left,
- int shCount, int sign)
-{
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* if shifting more that 3 bytes */
- if (shCount >= 24)
- {
- shCount -= 24;
- if (shCount)
- shiftR1Left2Result (left, MSB32, result, LSB, shCount, sign);
- else
- movLeft2Result (left, MSB32, result, LSB, sign);
- addSign (result, MSB16, sign);
- }
- else if (shCount >= 16)
- {
- shCount -= 16;
- if (shCount)
- shiftR2Left2Result (left, MSB24, result, LSB, shCount, sign);
- else
- {
- movLeft2Result (left, MSB24, result, LSB, 0);
- movLeft2Result (left, MSB32, result, MSB16, sign);
- }
- addSign (result, MSB24, sign);
- }
- else if (shCount >= 8)
- {
- shCount -= 8;
- if (shCount == 1)
- shiftRLong (left, MSB16, result, sign);
- else if (shCount == 0)
- {
- movLeft2Result (left, MSB16, result, LSB, 0);
- movLeft2Result (left, MSB24, result, MSB16, 0);
- movLeft2Result (left, MSB32, result, MSB24, sign);
- addSign (result, MSB32, sign);
- }
- else
- {
- shiftR2Left2Result (left, MSB16, result, LSB, shCount, 0);
- shiftLLeftOrResult (left, MSB32, result, MSB16, 8 - shCount);
- /* the last shift is signed */
- shiftR1Left2Result (left, MSB32, result, MSB24, shCount, sign);
- addSign (result, MSB32, sign);
- }
- }
- else
- { /* 1 <= shCount <= 7 */
- if (shCount <= 2)
- {
- shiftRLong (left, LSB, result, sign);
- if (shCount == 2)
- shiftRLong (result, LSB, result, sign);
- }
- else
- {
- shiftR2Left2Result (left, LSB, result, LSB, shCount, 0);
- shiftLLeftOrResult (left, MSB24, result, MSB16, 8 - shCount);
- shiftR2Left2Result (left, MSB24, result, MSB24, shCount, sign);
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* genRightShiftLiteral - right shifting by known count */
-/*-----------------------------------------------------------------*/
-static void
-genRightShiftLiteral (operand * left,
- operand * right,
- operand * result,
- iCode * ic,
- int sign)
-{
- int shCount = (int) floatFromVal (AOP (right)->aopu.aop_lit);
- int size;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- freeAsmop (right, NULL, ic, TRUE);
-
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
-#if VIEW_SIZE
- emitcode ("; shift right ", "result %d, left %d", AOP_SIZE (result),
- AOP_SIZE (left));
-#endif
-
- size = getDataSize (left);
- /* test the LEFT size !!! */
-
- /* I suppose that the left size >= result size */
- if (shCount == 0)
- {
- size = getDataSize (result);
- while (size--)
- movLeft2Result (left, size, result, size, 0);
- }
-
- else if (shCount >= (size * 8))
- {
- if (sign)
- /* get sign in acc.7 */
- MOVA (aopGet (AOP (left), size - 1, FALSE, FALSE));
- addSign (result, LSB, sign);
- }
- else
- {
- switch (size)
- {
- case 1:
- genrshOne (result, left, shCount, sign);
- break;
-
- case 2:
- genrshTwo (result, left, shCount, sign);
- break;
-
- case 4:
- genrshFour (result, left, shCount, sign);
- break;
- default:
- break;
- }
-
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* genSignedRightShift - right shift of signed number */
-/*-----------------------------------------------------------------*/
-static void
-genSignedRightShift (iCode * ic)
-{
- operand *right, *left, *result;
- int size, offset;
- char *l;
- symbol *tlbl, *tlbl1;
-
- /* we do it the hard way put the shift count in b
- and loop thru preserving the sign */
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- right = IC_RIGHT (ic);
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
-
- aopOp (right, ic, FALSE);
-
-
- if (AOP_TYPE (right) == AOP_LIT)
- {
- genRightShiftLiteral (left, right, result, ic, 1);
- return;
- }
- /* shift count is unknown then we have to form
- a loop get the loop count in B : Note: we take
- only the lower order byte since shifting
- more that 32 bits make no sense anyway, ( the
- largest size of an object can be only 32 bits ) */
-
- emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- emitcode ("inc", "b");
- freeAsmop (right, NULL, ic, TRUE);
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- /* now move the left to the result if they are not the
- same */
- if (!sameRegs (AOP (left), AOP (result)) &&
- AOP_SIZE (result) > 1)
- {
-
- size = AOP_SIZE (result);
- offset = 0;
- while (size--)
- {
- l = aopGet (AOP (left), offset, FALSE, TRUE);
- if (*l == '@' && IS_AOP_PREG (result))
- {
-
- emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offset);
- }
- else
- aopPut (AOP (result), l, offset);
- offset++;
- }
- }
-
- /* mov the highest order bit to OVR */
- tlbl = newiTempLabel (NULL);
- tlbl1 = newiTempLabel (NULL);
-
- size = AOP_SIZE (result);
- offset = size - 1;
- emitcode ("mov", "a,%s", aopGet (AOP (left), offset, FALSE, FALSE));
- emitcode ("rlc", "a");
- emitcode ("mov", "ov,c");
- /* if it is only one byte then */
- if (size == 1)
- {
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
- emitcode ("sjmp", "%05d_DS_", tlbl1->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- emitcode ("mov", "c,ov");
- emitcode ("rrc", "a");
- emitcode ("", "%05d_DS_:", tlbl1->key + 100);
- emitcode ("djnz", "b,%05d_DS_", tlbl->key + 100);
- aopPut (AOP (result), "a", 0);
- goto release;
- }
-
- reAdjustPreg (AOP (result));
- emitcode ("sjmp", "%05d_DS_", tlbl1->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- emitcode ("mov", "c,ov");
- while (size--)
- {
- l = aopGet (AOP (result), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("rrc", "a");
- aopPut (AOP (result), "a", offset--);
- }
- reAdjustPreg (AOP (result));
- emitcode ("", "%05d_DS_:", tlbl1->key + 100);
- emitcode ("djnz", "b,%05d_DS_", tlbl->key + 100);
-
-release:
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genRightShift - generate code for right shifting */
-/*-----------------------------------------------------------------*/
-static void
-genRightShift (iCode * ic)
-{
- operand *right, *left, *result;
- sym_link *retype;
- int size, offset;
- char *l;
- symbol *tlbl, *tlbl1;
-
- /* if signed then we do it the hard way preserve the
- sign bit moving it inwards */
- retype = getSpec (operandType (IC_RESULT (ic)));
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- if (!SPEC_USIGN (retype))
- {
- genSignedRightShift (ic);
- return;
- }
-
- /* signed & unsigned types are treated the same : i.e. the
- signed is NOT propagated inwards : quoting from the
- ANSI - standard : "for E1 >> E2, is equivalent to division
- by 2**E2 if unsigned or if it has a non-negative value,
- otherwise the result is implementation defined ", MY definition
- is that the sign does not get propagated */
-
- right = IC_RIGHT (ic);
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
-
- aopOp (right, ic, FALSE);
-
- /* if the shift count is known then do it
- as efficiently as possible */
- if (AOP_TYPE (right) == AOP_LIT)
- {
- genRightShiftLiteral (left, right, result, ic, 0);
- return;
- }
-
- /* shift count is unknown then we have to form
- a loop get the loop count in B : Note: we take
- only the lower order byte since shifting
- more that 32 bits make no sense anyway, ( the
- largest size of an object can be only 32 bits ) */
-
- emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- emitcode ("inc", "b");
- freeAsmop (right, NULL, ic, TRUE);
- aopOp (left, ic, FALSE);
- aopOp (result, ic, FALSE);
-
- /* now move the left to the result if they are not the
- same */
- if (!sameRegs (AOP (left), AOP (result)) &&
- AOP_SIZE (result) > 1)
- {
-
- size = AOP_SIZE (result);
- offset = 0;
- while (size--)
- {
- l = aopGet (AOP (left), offset, FALSE, TRUE);
- if (*l == '@' && IS_AOP_PREG (result))
- {
-
- emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offset);
- }
- else
- aopPut (AOP (result), l, offset);
- offset++;
- }
- }
-
- tlbl = newiTempLabel (NULL);
- tlbl1 = newiTempLabel (NULL);
- size = AOP_SIZE (result);
- offset = size - 1;
-
- /* if it is only one byte then */
- if (size == 1)
- {
- l = aopGet (AOP (left), 0, FALSE, FALSE);
- MOVA (l);
- emitcode ("sjmp", "%05d_DS_", tlbl1->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- CLRC;
- emitcode ("rrc", "a");
- emitcode ("", "%05d_DS_:", tlbl1->key + 100);
- emitcode ("djnz", "b,%05d_DS_", tlbl->key + 100);
- aopPut (AOP (result), "a", 0);
- goto release;
- }
-
- reAdjustPreg (AOP (result));
- emitcode ("sjmp", "%05d_DS_", tlbl1->key + 100);
- emitcode ("", "%05d_DS_:", tlbl->key + 100);
- CLRC;
- while (size--)
- {
- l = aopGet (AOP (result), offset, FALSE, FALSE);
- MOVA (l);
- emitcode ("rrc", "a");
- aopPut (AOP (result), "a", offset--);
- }
- reAdjustPreg (AOP (result));
-
- emitcode ("", "%05d_DS_:", tlbl1->key + 100);
- emitcode ("djnz", "b,%05d_DS_", tlbl->key + 100);
-
-release:
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genUnpackBits - generates code for unpacking bits */
-/*-----------------------------------------------------------------*/
-static void
-genUnpackBits (operand * result, char *rname, int ptype)
-{
- int shCnt;
- int rlen = 0;
- sym_link *etype;
- int offset = 0;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- etype = getSpec (operandType (result));
-
- /* read the first byte */
- switch (ptype)
- {
-
- case POINTER:
- case IPOINTER:
- emitcode ("mov", "a,@%s", rname);
- break;
-
- case PPOINTER:
- emitcode ("movx", "a,@%s", rname);
- break;
-
- case FPOINTER:
- emitcode ("movx", "a,@dptr");
- break;
-
- case CPOINTER:
- emitcode ("clr", "a");
- emitcode ("movc", "a", "@a+dptr");
- break;
-
- case GPOINTER:
- emitcode ("lcall", "__gptrget");
- break;
- }
-
- /* if we have bitdisplacement then it fits */
- /* into this byte completely or if length is */
- /* less than a byte */
- if ((shCnt = SPEC_BSTR (etype)) ||
- (SPEC_BLEN (etype) <= 8))
- {
-
- /* shift right acc */
- AccRsh (shCnt);
-
- emitcode ("anl", "a,#0x%02x",
- ((unsigned char) -1) >> (8 - SPEC_BLEN (etype)));
- aopPut (AOP (result), "a", offset);
- return;
- }
-
- /* bit field did not fit in a byte */
- rlen = SPEC_BLEN (etype) - 8;
- aopPut (AOP (result), "a", offset++);
-
- while (1)
- {
-
- switch (ptype)
- {
- case POINTER:
- case IPOINTER:
- emitcode ("inc", "%s", rname);
- emitcode ("mov", "a,@%s", rname);
- break;
-
- case PPOINTER:
- emitcode ("inc", "%s", rname);
- emitcode ("movx", "a,@%s", rname);
- break;
-
- case FPOINTER:
- emitcode ("inc", "dptr");
- emitcode ("movx", "a,@dptr");
- break;
-
- case CPOINTER:
- emitcode ("clr", "a");
- emitcode ("inc", "dptr");
- emitcode ("movc", "a", "@a+dptr");
- break;
-
- case GPOINTER:
- emitcode ("inc", "dptr");
- emitcode ("lcall", "__gptrget");
- break;
- }
-
- rlen -= 8;
- /* if we are done */
- if (rlen <= 0)
- break;
-
- aopPut (AOP (result), "a", offset++);
-
- }
-
- if (rlen)
- {
- emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (-rlen));
- aopPut (AOP (result), "a", offset);
- }
-
- return;
-}
-
-
-/*-----------------------------------------------------------------*/
-/* genDataPointerGet - generates code when ptr offset is known */
-/*-----------------------------------------------------------------*/
-static void
-genDataPointerGet (operand * left,
- operand * result,
- iCode * ic)
-{
- char *l;
- char buffer[256];
- int size, offset = 0;
- aopOp (result, ic, TRUE);
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- /* get the string representation of the name */
- l = aopGet (AOP (left), 0, FALSE, TRUE);
- size = AOP_SIZE (result);
- // tsd, was l+1 - the underline `_' prefix was being stripped
- while (size--)
- {
- if (offset)
- sprintf (buffer, "(%s + %d)", l, offset);
- else
- sprintf (buffer, "%s", l);
- aopPut (AOP (result), buffer, offset++);
- }
-
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genNearPointerGet - emitcode for near pointer fetch */
-/*-----------------------------------------------------------------*/
-static void
-genNearPointerGet (operand * left,
- operand * result,
- iCode * ic)
-{
- asmop *aop = NULL;
- regs *preg = NULL;
- char *rname;
- sym_link *rtype, *retype;
- sym_link *ltype = operandType (left);
- char buffer[80];
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- rtype = operandType (result);
- retype = getSpec (rtype);
-
- aopOp (left, ic, FALSE);
-
- /* if left is rematerialisable and
- result is not bit variable type and
- the left is pointer to data space i.e
- lower 128 bytes of space */
- if (AOP_TYPE (left) == AOP_IMMD &&
- !IS_BITVAR (retype) &&
- DCL_TYPE (ltype) == POINTER)
- {
- genDataPointerGet (left, result, ic);
- return;
- }
-
- /* if the value is already in a pointer register
- then don't need anything more */
- if (!AOP_INPREG (AOP (left)))
- {
- /* otherwise get a free pointer register */
- aop = newAsmop (0);
- preg = getFreePtr (ic, &aop, FALSE);
- emitcode ("mov", "%s,%s",
- preg->name,
- aopGet (AOP (left), 0, FALSE, TRUE));
- rname = preg->name;
- }
- else
- rname = aopGet (AOP (left), 0, FALSE, FALSE);
-
- freeAsmop (left, NULL, ic, TRUE);
- aopOp (result, ic, FALSE);
-
- /* if bitfield then unpack the bits */
- if (IS_BITVAR (retype))
- genUnpackBits (result, rname, POINTER);
- else
- {
- /* we have can just get the values */
- int size = AOP_SIZE (result);
- int offset = 0;
-
- while (size--)
- {
- if (IS_AOP_PREG (result) || AOP_TYPE (result) == AOP_STK)
- {
-
- emitcode ("mov", "a,@%s", rname);
- aopPut (AOP (result), "a", offset);
- }
- else
- {
- sprintf (buffer, "@%s", rname);
- aopPut (AOP (result), buffer, offset);
- }
- offset++;
- if (size)
- emitcode ("inc", "%s", rname);
- }
- }
-
- /* now some housekeeping stuff */
- if (aop)
- {
- /* we had to allocate for this iCode */
- freeAsmop (NULL, aop, ic, TRUE);
- }
- else
- {
- /* we did not allocate which means left
- already in a pointer register, then
- if size > 0 && this could be used again
- we have to point it back to where it
- belongs */
- if (AOP_SIZE (result) > 1 &&
- !OP_SYMBOL (left)->remat &&
- (OP_SYMBOL (left)->liveTo > ic->seq ||
- ic->depth))
- {
- int size = AOP_SIZE (result) - 1;
- while (size--)
- emitcode ("dec", "%s", rname);
- }
- }
-
- /* done */
- freeAsmop (result, NULL, ic, TRUE);
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genPagedPointerGet - emitcode for paged pointer fetch */
-/*-----------------------------------------------------------------*/
-static void
-genPagedPointerGet (operand * left,
- operand * result,
- iCode * ic)
-{
- asmop *aop = NULL;
- regs *preg = NULL;
- char *rname;
- sym_link *rtype, *retype;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- rtype = operandType (result);
- retype = getSpec (rtype);
-
- aopOp (left, ic, FALSE);
-
- /* if the value is already in a pointer register
- then don't need anything more */
- if (!AOP_INPREG (AOP (left)))
- {
- /* otherwise get a free pointer register */
- aop = newAsmop (0);
- preg = getFreePtr (ic, &aop, FALSE);
- emitcode ("mov", "%s,%s",
- preg->name,
- aopGet (AOP (left), 0, FALSE, TRUE));
- rname = preg->name;
- }
- else
- rname = aopGet (AOP (left), 0, FALSE, FALSE);
-
- freeAsmop (left, NULL, ic, TRUE);
- aopOp (result, ic, FALSE);
-
- /* if bitfield then unpack the bits */
- if (IS_BITVAR (retype))
- genUnpackBits (result, rname, PPOINTER);
- else
- {
- /* we have can just get the values */
- int size = AOP_SIZE (result);
- int offset = 0;
-
- while (size--)
- {
-
- emitcode ("movx", "a,@%s", rname);
- aopPut (AOP (result), "a", offset);
-
- offset++;
-
- if (size)
- emitcode ("inc", "%s", rname);
- }
- }
-
- /* now some housekeeping stuff */
- if (aop)
- {
- /* we had to allocate for this iCode */
- freeAsmop (NULL, aop, ic, TRUE);
- }
- else
- {
- /* we did not allocate which means left
- already in a pointer register, then
- if size > 0 && this could be used again
- we have to point it back to where it
- belongs */
- if (AOP_SIZE (result) > 1 &&
- !OP_SYMBOL (left)->remat &&
- (OP_SYMBOL (left)->liveTo > ic->seq ||
- ic->depth))
- {
- int size = AOP_SIZE (result) - 1;
- while (size--)
- emitcode ("dec", "%s", rname);
- }
- }
-
- /* done */
- freeAsmop (result, NULL, ic, TRUE);
-
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genFarPointerGet - gget value from far space */
-/*-----------------------------------------------------------------*/
-static void
-genFarPointerGet (operand * left,
- operand * result, iCode * ic)
-{
- int size, offset;
- sym_link *retype = getSpec (operandType (result));
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- aopOp (left, ic, FALSE);
-
- /* if the operand is already in dptr
- then we do nothing else we move the value to dptr */
- if (AOP_TYPE (left) != AOP_STR)
- {
- /* if this is remateriazable */
- if (AOP_TYPE (left) == AOP_IMMD)
- emitcode ("mov", "dptr,%s", aopGet (AOP (left), 0, TRUE, FALSE));
- else
- { /* we need to get it byte by byte */
- emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE));
- emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE));
- }
- }
- }
- /* so dptr know contains the address */
- freeAsmop (left, NULL, ic, TRUE);
- aopOp (result, ic, FALSE);
-
- /* if bit then unpack */
- if (IS_BITVAR (retype))
- genUnpackBits (result, "dptr", FPOINTER);
- else
- {
- size = AOP_SIZE (result);
- offset = 0;
-
- while (size--)
- {
- emitcode ("movx", "a,@dptr");
- aopPut (AOP (result), "a", offset++);
- if (size)
- emitcode ("inc", "dptr");
- }
- }
-
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* emitcodePointerGet - gget value from code space */
-/*-----------------------------------------------------------------*/
-static void
-emitcodePointerGet (operand * left,
- operand * result, iCode * ic)
-{
- int size, offset;
- sym_link *retype = getSpec (operandType (result));
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- aopOp (left, ic, FALSE);
-
- /* if the operand is already in dptr
- then we do nothing else we move the value to dptr */
- if (AOP_TYPE (left) != AOP_STR)
- {
- /* if this is remateriazable */
- if (AOP_TYPE (left) == AOP_IMMD)
- emitcode ("mov", "dptr,%s", aopGet (AOP (left), 0, TRUE, FALSE));
- else
- { /* we need to get it byte by byte */
- emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE));
- emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE));
- }
- }
- }
- /* so dptr know contains the address */
- freeAsmop (left, NULL, ic, TRUE);
- aopOp (result, ic, FALSE);
-
- /* if bit then unpack */
- if (IS_BITVAR (retype))
- genUnpackBits (result, "dptr", CPOINTER);
- else
- {
- size = AOP_SIZE (result);
- offset = 0;
-
- while (size--)
- {
- emitcode ("clr", "a");
- emitcode ("movc", "a,@a+dptr");
- aopPut (AOP (result), "a", offset++);
- if (size)
- emitcode ("inc", "dptr");
- }
- }
-
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genGenPointerGet - gget value from generic pointer space */
-/*-----------------------------------------------------------------*/
-static void
-genGenPointerGet (operand * left,
- operand * result, iCode * ic)
-{
- int size, offset;
- sym_link *retype = getSpec (operandType (result));
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- aopOp (left, ic, FALSE);
-
- /* if the operand is already in dptr
- then we do nothing else we move the value to dptr */
- if (AOP_TYPE (left) != AOP_STR)
- {
- /* if this is remateriazable */
- if (AOP_TYPE (left) == AOP_IMMD)
- {
- emitcode ("mov", "dptr,%s", aopGet (AOP (left), 0, TRUE, FALSE));
- emitcode ("mov", "b,#%d", pointerCode (retype));
- }
- else
- { /* we need to get it byte by byte */
-
- emitcode ("movf", "%s,w", aopGet (AOP (left), 0, FALSE, FALSE));
- emitcode ("movwf", "FSR");
- /*
- emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
- emitcode("mov","b,%s",aopGet(AOP(left),3,FALSE,FALSE));
- }
- else
- {
- emitcode("mov","b,%s",aopGet(AOP(left),2,FALSE,FALSE));
- }
- */
- }
- }
- /* so dptr know contains the address */
- freeAsmop (left, NULL, ic, TRUE);
- aopOp (result, ic, FALSE);
-
- /* if bit then unpack */
- if (IS_BITVAR (retype))
- genUnpackBits (result, "dptr", GPOINTER);
- else
- {
- size = AOP_SIZE (result);
- offset = 0;
-
- while (size--)
- {
- //emitcode("lcall","__gptrget");
- emitcode ("movf", "indf,w");
- //aopPut(AOP(result),"a",offset++);
- emitcode ("movwf", "%s",
- aopGet (AOP (result), offset++, FALSE, FALSE));
- if (size)
- emitcode ("incf", "fsr,f");
- }
- }
-
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genPointerGet - generate code for pointer get */
-/*-----------------------------------------------------------------*/
-static void
-genPointerGet (iCode * ic)
-{
- operand *left, *result;
- sym_link *type, *etype;
- int p_type;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- left = IC_LEFT (ic);
- result = IC_RESULT (ic);
-
- /* depending on the type of pointer we need to
- move it to the correct pointer register */
- type = operandType (left);
- etype = getSpec (type);
- /* if left is of type of pointer then it is simple */
- if (IS_PTR (type) && !IS_FUNC (type->next))
- p_type = DCL_TYPE (type);
- else
- {
- /* we have to go by the storage class */
- p_type = PTR_TYPE (SPEC_OCLS (etype));
-
-/* if (SPEC_OCLS(etype)->codesp ) { */
-/* p_type = CPOINTER ; */
-/* } */
-/* else */
-/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */
-/* p_type = FPOINTER ; */
-/* else */
-/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */
-/* p_type = PPOINTER; */
-/* else */
-/* if (SPEC_OCLS(etype) == idata ) */
-/* p_type = IPOINTER; */
-/* else */
-/* p_type = POINTER ; */
- }
-
- /* now that we have the pointer type we assign
- the pointer values */
- switch (p_type)
- {
-
- case POINTER:
- case IPOINTER:
- genNearPointerGet (left, result, ic);
- break;
-
- case PPOINTER:
- genPagedPointerGet (left, result, ic);
- break;
-
- case FPOINTER:
- genFarPointerGet (left, result, ic);
- break;
-
- case CPOINTER:
- emitcodePointerGet (left, result, ic);
- break;
-
- case GPOINTER:
- genGenPointerGet (left, result, ic);
- break;
- }
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genPackBits - generates code for packed bit storage */
-/*-----------------------------------------------------------------*/
-static void
-genPackBits (sym_link * etype,
- operand * right,
- char *rname, int p_type)
-{
- int shCount = 0;
- int offset = 0;
- int rLen = 0;
- int blen, bstr;
- char *l;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- blen = SPEC_BLEN (etype);
- bstr = SPEC_BSTR (etype);
-
- l = aopGet (AOP (right), offset++, FALSE, FALSE);
- MOVA (l);
-
- /* if the bit lenth is less than or */
- /* it exactly fits a byte then */
- if (SPEC_BLEN (etype) <= 8)
- {
- shCount = SPEC_BSTR (etype);
-
- /* shift left acc */
- AccLsh (shCount);
-
- if (SPEC_BLEN (etype) < 8)
- { /* if smaller than a byte */
-
-
- switch (p_type)
- {
- case POINTER:
- emitcode ("mov", "b,a");
- emitcode ("mov", "a,@%s", rname);
- break;
-
- case FPOINTER:
- emitcode ("mov", "b,a");
- emitcode ("movx", "a,@dptr");
- break;
-
- case GPOINTER:
- emitcode ("push", "b");
- emitcode ("push", "acc");
- emitcode ("lcall", "__gptrget");
- emitcode ("pop", "b");
- break;
- }
-
- emitcode ("anl", "a,#0x%02x", (unsigned char)
- ((unsigned char) (0xFF << (blen + bstr)) |
- (unsigned char) (0xFF >> (8 - bstr))));
- emitcode ("orl", "a,b");
- if (p_type == GPOINTER)
- emitcode ("pop", "b");
- }
- }
-
- switch (p_type)
- {
- case POINTER:
- emitcode ("mov", "@%s,a", rname);
- break;
-
- case FPOINTER:
- emitcode ("movx", "@dptr,a");
- break;
-
- case GPOINTER:
- DEBUGemitcode (";lcall", "__gptrput");
- break;
- }
-
- /* if we r done */
- if (SPEC_BLEN (etype) <= 8)
- return;
-
- emitcode ("inc", "%s", rname);
- rLen = SPEC_BLEN (etype);
-
- /* now generate for lengths greater than one byte */
- while (1)
- {
-
- l = aopGet (AOP (right), offset++, FALSE, TRUE);
-
- rLen -= 8;
- if (rLen <= 0)
- break;
-
- switch (p_type)
- {
- case POINTER:
- if (*l == '@')
- {
- MOVA (l);
- emitcode ("mov", "@%s,a", rname);
- }
- else
- emitcode ("mov", "@%s,%s", rname, l);
- break;
-
- case FPOINTER:
- MOVA (l);
- emitcode ("movx", "@dptr,a");
- break;
-
- case GPOINTER:
- MOVA (l);
- DEBUGemitcode (";lcall", "__gptrput");
- break;
- }
- emitcode ("inc", "%s", rname);
- }
-
- MOVA (l);
-
- /* last last was not complete */
- if (rLen)
- {
- /* save the byte & read byte */
- switch (p_type)
- {
- case POINTER:
- emitcode ("mov", "b,a");
- emitcode ("mov", "a,@%s", rname);
- break;
-
- case FPOINTER:
- emitcode ("mov", "b,a");
- emitcode ("movx", "a,@dptr");
- break;
-
- case GPOINTER:
- emitcode ("push", "b");
- emitcode ("push", "acc");
- emitcode ("lcall", "__gptrget");
- emitcode ("pop", "b");
- break;
- }
-
- emitcode ("anl", "a,#0x%02x", ((unsigned char) -1 << -rLen));
- emitcode ("orl", "a,b");
- }
-
- if (p_type == GPOINTER)
- emitcode ("pop", "b");
-
- switch (p_type)
- {
-
- case POINTER:
- emitcode ("mov", "@%s,a", rname);
- break;
-
- case FPOINTER:
- emitcode ("movx", "@dptr,a");
- break;
-
- case GPOINTER:
- DEBUGemitcode (";lcall", "__gptrput");
- break;
- }
-}
-/*-----------------------------------------------------------------*/
-/* genDataPointerSet - remat pointer to data space */
-/*-----------------------------------------------------------------*/
-static void
-genDataPointerSet (operand * right,
- operand * result,
- iCode * ic)
-{
- int size, offset = 0;
- char *l, buffer[256];
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- aopOp (right, ic, FALSE);
-
- l = aopGet (AOP (result), 0, FALSE, TRUE);
- size = AOP_SIZE (right);
- // tsd, was l+1 - the underline `_' prefix was being stripped
- while (size--)
- {
- if (offset)
- sprintf (buffer, "(%s + %d)", l, offset);
- else
- sprintf (buffer, "%s", l);
-
- if (AOP_TYPE (right) == AOP_LIT)
- {
- unsigned int lit = floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
- lit = lit >> (8 * offset);
- if (lit)
- {
- emitcode ("movlw", "%s", lit);
- emitcode ("movwf", "%s", buffer);
- }
- else
- emitcode ("clrf", "%s", buffer);
- }
- else
- {
- emitcode ("movf", "%s,w", aopGet (AOP (right), offset, FALSE, FALSE));
- emitcode ("movwf", "%s", buffer);
- }
-
- offset++;
- }
-
- freeAsmop (right, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genNearPointerSet - emitcode for near pointer put */
-/*-----------------------------------------------------------------*/
-static void
-genNearPointerSet (operand * right,
- operand * result,
- iCode * ic)
-{
- asmop *aop = NULL;
- char *l;
- sym_link *retype;
- sym_link *ptype = operandType (result);
-
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- retype = getSpec (operandType (right));
-
- aopOp (result, ic, FALSE);
-
- /* if the result is rematerializable &
- in data space & not a bit variable */
- if (AOP_TYPE (result) == AOP_IMMD &&
- DCL_TYPE (ptype) == POINTER &&
- !IS_BITVAR (retype))
- {
- genDataPointerSet (right, result, ic);
- return;
- }
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- /* if the value is already in a pointer register
- then don't need anything more */
- if (!AOP_INPREG (AOP (result)))
- {
- /* otherwise get a free pointer register */
- //aop = newAsmop(0);
- //preg = getFreePtr(ic,&aop,FALSE);
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- //emitcode("mov","%s,%s",
- // preg->name,
- // aopGet(AOP(result),0,FALSE,TRUE));
- //rname = preg->name ;
- emitcode ("movwf", "fsr");
- } // else
- // rname = aopGet(AOP(result),0,FALSE,FALSE);
-
- freeAsmop (result, NULL, ic, TRUE);
- aopOp (right, ic, FALSE);
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
-
- /* if bitfield then unpack the bits */
- if (IS_BITVAR (retype))
- {
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "The programmer is obviously confused");
- //genPackBits (retype,right,rname,POINTER);
- exit (1);
- }
- else
- {
- /* we have can just get the values */
- int size = AOP_SIZE (right);
- int offset = 0;
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- while (size--)
- {
- l = aopGet (AOP (right), offset, FALSE, TRUE);
- if (*l == '@')
- {
- //MOVA(l);
- //emitcode("mov","@%s,a",rname);
- emitcode ("movf", "indf,w ;1");
- }
- else
- {
-
- if (AOP_TYPE (right) == AOP_LIT)
- {
- unsigned int lit = floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
- if (lit)
- {
- emitcode ("movlw", "%s", l);
- emitcode ("movwf", "indf ;2");
- }
- else
- emitcode ("clrf", "indf");
- }
- else
- {
- emitcode ("movf", "%s,w", l);
- emitcode ("movwf", "indf ;2");
- }
- //emitcode("mov","@%s,%s",rname,l);
- }
- if (size)
- emitcode ("incf", "fsr,f ;3");
- //emitcode("inc","%s",rname);
- offset++;
- }
- }
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* now some housekeeping stuff */
- if (aop)
- {
- /* we had to allocate for this iCode */
- freeAsmop (NULL, aop, ic, TRUE);
- }
- else
- {
- /* we did not allocate which means left
- already in a pointer register, then
- if size > 0 && this could be used again
- we have to point it back to where it
- belongs */
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- if (AOP_SIZE (right) > 1 &&
- !OP_SYMBOL (result)->remat &&
- (OP_SYMBOL (result)->liveTo > ic->seq ||
- ic->depth))
- {
- int size = AOP_SIZE (right) - 1;
- while (size--)
- emitcode ("decf", "fsr,f");
- //emitcode("dec","%s",rname);
- }
- }
-
- DEBUGemitcode ("; ***", "%s %d", __FUNCTION__, __LINE__);
- /* done */
- freeAsmop (right, NULL, ic, TRUE);
-
-