- offset++;
- }
- _endLazyDPSEvaluation ();
-
- /* the last byte depending on type */
- {
- int gpVal = pointerTypeToGPByte(p_type, NULL, NULL);
- char gpValStr[10];
-
- if (gpVal == -1)
- {
- // pointerTypeToGPByte will have bitched.
- exit(1);
- }
-
- SNPRINTF(gpValStr, sizeof(gpValStr), "#0x%x", gpVal);
- aopPut (AOP (result), gpValStr, GPTRSIZE - 1);
- }
- goto release;
- }
-
- /* just copy the pointers */
- size = AOP_SIZE (result);
- offset = 0;
- _startLazyDPSEvaluation ();
- while (size--)
- {
- aopPut (AOP (result),
- aopGet (AOP (right), offset, FALSE, FALSE, NULL),
- offset);
- offset++;
- }
- _endLazyDPSEvaluation ();
- goto release;
- }
-
- /* so we now know that the size of destination is greater
- than the size of the source */
- /* we move to result for the size of source */
- size = AOP_SIZE (right);
- offset = 0;
- _startLazyDPSEvaluation ();
- while (size--)
- {
- aopPut (AOP (result),
- aopGet (AOP (right), offset, FALSE, FALSE, NULL),
- offset);
- offset++;
- }
- _endLazyDPSEvaluation ();
-
- /* now depending on the sign of the source && destination */
- size = AOP_SIZE (result) - AOP_SIZE (right);
- /* if unsigned or not an integral type */
- /* also, if the source is a bit, we don't need to sign extend, because
- * it can't possibly have set the sign bit.
- */
- if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE (right) == AOP_CRY)
- {
- while (size--)
- {
- aopPut (AOP (result), zero, offset++);
- }
- }
- else
- {
- /* we need to extend the sign :{ */
- MOVA (aopGet (AOP (right), AOP_SIZE (right) - 1,
- FALSE, FALSE, NULL));
- emitcode ("rlc", "a");
- emitcode ("subb", "a,acc");
- while (size--)
- aopPut (AOP (result), "a", offset++);
- }
-
- /* we are done hurray !!!! */
-
-release:
- freeAsmop (right, NULL, ic, TRUE);
- freeAsmop (result, NULL, ic, TRUE);
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genDjnz - generate decrement & jump if not zero instrucion */
-/*-----------------------------------------------------------------*/
-static int
-genDjnz (iCode * ic, iCode * ifx)
-{
- symbol *lbl, *lbl1;
- if (!ifx)
- return 0;
-
- /* if the if condition has a false label
- then we cannot save */
- if (IC_FALSE (ifx))
- return 0;
-
- /* if the minus is not of the form
- a = a - 1 */
- if (!isOperandEqual (IC_RESULT (ic), IC_LEFT (ic)) ||
- !IS_OP_LITERAL (IC_RIGHT (ic)))
- return 0;
-
- if (operandLitValue (IC_RIGHT (ic)) != 1)
- return 0;
-
- /* if the size of this greater than one then no
- saving */
- if (getSize (operandType (IC_RESULT (ic))) > 1)
- return 0;
-
- /* otherwise we can save BIG */
- D(emitcode(";", "genDjnz"););
-
- lbl = newiTempLabel (NULL);
- lbl1 = newiTempLabel (NULL);
-
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
-
- if (AOP_NEEDSACC(IC_RESULT(ic)))
- {
- /* If the result is accessed indirectly via
- * the accumulator, we must explicitly write
- * it back after the decrement.
- */
- char *rByte = aopGet(AOP(IC_RESULT(ic)), 0, FALSE, FALSE, NULL);
-
- if (strcmp(rByte, "a"))
- {
- /* Something is hopelessly wrong */
- fprintf(stderr, "*** warning: internal error at %s:%d\n",
- __FILE__, __LINE__);
- /* We can just give up; the generated code will be inefficient,
- * but what the hey.
- */
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
- return 0;
- }
- emitcode ("dec", "%s", rByte);
- aopPut(AOP(IC_RESULT(ic)), rByte, 0);
- emitcode ("jnz", "!tlabel", lbl->key + 100);
- }
- else if (IS_AOP_PREG (IC_RESULT (ic)))
- {
- emitcode ("dec", "%s",
- aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE, NULL));
- emitcode ("mov", "a,%s", aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE, NULL));
- emitcode ("jnz", "!tlabel", lbl->key + 100);
- }
- else
- {
- emitcode ("djnz", "%s,!tlabel", aopGet (AOP (IC_RESULT (ic)), 0, FALSE, TRUE, NULL),
- lbl->key + 100);
- }
- emitcode ("sjmp", "!tlabel", lbl1->key + 100);
- emitcode ("", "!tlabeldef", lbl->key + 100);
- emitcode ("ljmp", "!tlabel", IC_TRUE (ifx)->key + 100);
- emitcode ("", "!tlabeldef", lbl1->key + 100);