+ _startLazyDPSEvaluation ();
+ while (size--)
+ {
+
+ genSetDPTR (0);
+ _flushLazyDPS ();
+
+ emitcode ("movx", "a,@dptr");
+ if (size)
+ emitcode ("inc", "dptr");
+
+ aopPut (AOP (result), "a", offset++);
+ }
+ _endLazyDPSEvaluation ();
+ }
+
+ 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));
+
+ aopOp (left, ic, FALSE, 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, FALSE));
+ }
+ else
+ { /* we need to get it byte by byte */
+ _startLazyDPSEvaluation ();
+ if (AOP_TYPE (left) != AOP_DPTR)
+ {
+ emitcode ("mov", "dpl,%s", aopGet (AOP (left), 0, FALSE, FALSE, TRUE));
+ emitcode ("mov", "dph,%s", aopGet (AOP (left), 1, FALSE, FALSE, TRUE));
+ if (options.model == MODEL_FLAT24)
+ emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE));
+ }
+ else
+ {
+ /* We need to generate a load to DPTR indirect through DPTR. */
+ D (emitcode (";", "gencodePointerGet -- indirection special case.");
+ );
+ emitcode ("push", "%s", aopGet (AOP (left), 0, FALSE, TRUE, TRUE));
+ emitcode ("push", "%s", aopGet (AOP (left), 1, FALSE, TRUE, TRUE));
+ if (options.model == MODEL_FLAT24)
+ emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE));
+ emitcode ("pop", "dph");
+ emitcode ("pop", "dpl");
+ }
+ _endLazyDPSEvaluation ();
+ }
+ }
+ /* so dptr know contains the address */
+ freeAsmop (left, NULL, ic, TRUE);
+ aopOp (result, ic, FALSE, TRUE);
+
+ /* if bit then unpack */
+ if (IS_BITVAR (retype))
+ genUnpackBits (result, "dptr", CPOINTER);
+ else
+ {
+ size = AOP_SIZE (result);
+ offset = 0;
+
+ _startLazyDPSEvaluation ();
+ while (size--)
+ {
+ genSetDPTR (0);
+ _flushLazyDPS ();
+
+ emitcode ("clr", "a");
+ emitcode ("movc", "a,@a+dptr");
+ if (size)
+ emitcode ("inc", "dptr");
+ aopPut (AOP (result), "a", offset++);
+ }
+ _endLazyDPSEvaluation ();
+ }
+
+ 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));
+ sym_link *letype = getSpec (operandType (left));
+
+ D (emitcode (";", "genGenPointerGet "); );
+
+ aopOp (left, ic, FALSE, TRUE);
+
+ /* 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, FALSE));
+ emitcode ("mov", "b,#%d", pointerCode (retype));
+ }
+ else
+ { /* we need to get it byte by byte */
+ _startLazyDPSEvaluation ();
+ if (AOP(left)->type==AOP_DPTR2) {
+ char *l;
+ l=aopGet(AOP(left),0,FALSE,FALSE,TRUE);
+ genSetDPTR(0);
+ _flushLazyDPS();
+ emitcode ("mov", "dpl,%s", l);
+ l=aopGet(AOP(left),1,FALSE,FALSE,TRUE);
+ genSetDPTR(0);
+ _flushLazyDPS();
+ emitcode ("mov", "dph,%s", l);
+ if (options.model == MODEL_FLAT24) {
+ l=aopGet(AOP(left),2,FALSE,FALSE,TRUE);
+ genSetDPTR(0);
+ _flushLazyDPS();
+ emitcode ("mov", "dpx,%s", l);
+ emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE));
+ } else {
+ emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE));
+ }
+ } else {
+ emitcode ("mov", "dpl,%s", aopGet (AOP(left),0,FALSE,FALSE,TRUE));
+ emitcode ("mov", "dph,%s", aopGet (AOP(left),1,FALSE,FALSE,TRUE));
+ if (options.model == MODEL_FLAT24) {
+ emitcode ("mov", "dpx,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE));
+ emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE));
+ } else {
+ emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,TRUE));
+ }
+ }
+ _endLazyDPSEvaluation ();
+ }
+ }
+ /* so dptr know contains the address */
+ freeAsmop (left, NULL, ic, TRUE);
+ aopOp (result, ic, FALSE, TRUE);
+
+ /* if bit then unpack */
+ if (IS_BITVAR (retype) || IS_BITVAR (letype))
+ genUnpackBits (result, "dptr", GPOINTER);
+ else
+ {
+ size = AOP_SIZE (result);
+ offset = 0;
+
+ while (size--)
+ {
+ emitcode ("lcall", "__gptrget");
+ aopPut (AOP (result), "a", offset++);
+ if (size)
+ emitcode ("inc", "dptr");
+ }
+ }
+
+ 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;
+
+ D (emitcode (";", "genPointerGet ");
+ );
+
+ 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));
+ }
+
+ /* 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;
+
+ blen = SPEC_BLEN (etype);
+ bstr = SPEC_BSTR (etype);
+
+ l = aopGet (AOP (right), offset++, FALSE, FALSE, TRUE);
+ 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)