- 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);
-
- /* get the string representation of the name */
- l = aopGet(AOP(left),0,FALSE,TRUE);
- size = AOP_SIZE(result);
- while (size--) {
- if (offset)
- sprintf(buffer,"(%s + %d)",l+1,offset);
- else
- sprintf(buffer,"%s",l+1);
- 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 ;
- link *rtype, *retype;
- link *ltype = operandType(left);
- char buffer[80];
-
- 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 ;
- link *rtype, *retype;
-
- 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 ;
- link *retype = getSpec(operandType(result));
-
- 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 ;
- link *retype = getSpec(operandType(result));
-
- 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");
- }
- }