- int size, offset = 0;
-
- /* special cases :- */
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
-
- aopOp (IC_LEFT(ic),ic,FALSE);
- aopOp (IC_RIGHT(ic),ic,FALSE);
- aopOp (IC_RESULT(ic),ic,TRUE);
-
- DEBUGpic14_AopType(__LINE__,IC_LEFT(ic),IC_RIGHT(ic),IC_RESULT(ic));
-
- /* if literal, literal on the right or
- if left requires ACC or right is already
- in ACC */
-
- if (AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) {
- operand *t = IC_RIGHT(ic);
- IC_RIGHT(ic) = IC_LEFT(ic);
- IC_LEFT(ic) = t;
- }
-
- /* if both left & right are in bit space */
- if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
- AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
- genPlusBits (ic);
- goto release ;
- }
-
- /* if left in bit space & right literal */
- if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
- AOP_TYPE(IC_RIGHT(ic)) == AOP_LIT) {
- /* if result in bit space */
- if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){
- if((unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit) != 0L) {
- emitpcode(POC_MOVLW, popGet(AOP(IC_RESULT(ic)),0));
- if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
- emitpcode(POC_BTFSC, popGet(AOP(IC_LEFT(ic)),0));
- emitpcode(POC_XORWF, popGet(AOP(IC_RESULT(ic)),0));
- }
- } else {
- size = pic14_getDataSize(IC_RESULT(ic));
- while (size--) {
- MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
- pic14_emitcode("addc","a,#00 ;%d",__LINE__);
- aopPut(AOP(IC_RESULT(ic)),"a",offset++);
- }
- }
- goto release ;
- }
-
- /* if I can do an increment instead
- of add then GOOD for ME */
- if (genPlusIncr (ic) == TRUE)
- goto release;
-
- size = pic14_getDataSize(IC_RESULT(ic));
-
- if(AOP(IC_RIGHT(ic))->type == AOP_LIT) {
- /* Add a literal to something else */
- //bool know_W=0;
- unsigned lit = (unsigned) floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit);
- // unsigned l1=0;
-
- // offset = 0;
- DEBUGpic14_emitcode(";","adding lit to something. size %d",size);
-
- genAddLit (ic, lit);
- goto release;
-
- } else if(AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
-
- pic14_emitcode(";bitadd","right is bit: %s",aopGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
- pic14_emitcode(";bitadd","left is bit: %s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- pic14_emitcode(";bitadd","result is bit: %s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-
- /* here we are adding a bit to a char or int */
- if(size == 1) {
- if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
-
- emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0));
- emitpcode(POC_INCF , popGet(AOP(IC_RESULT(ic)),0));
-
- pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(IC_RIGHT(ic))->aopu.aop_dir,
- AOP(IC_RIGHT(ic))->aopu.aop_dir);
- pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
- } else {
-
- if(AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
- emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0));
- emitpcode(POC_XORLW , popGetLit(1));
-
- pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(IC_RIGHT(ic))->aopu.aop_dir,
- AOP(IC_RIGHT(ic))->aopu.aop_dir);
- pic14_emitcode(" xorlw","1");
- } else {
- emitpcode(POC_MOVFW , popGet(AOP(IC_LEFT(ic)),0));
- emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0));
- emitpcode(POC_INCFW , popGet(AOP(IC_LEFT(ic)),0));
-
- pic14_emitcode("movf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(IC_RIGHT(ic))->aopu.aop_dir,
- AOP(IC_RIGHT(ic))->aopu.aop_dir);
- pic14_emitcode(" incf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- }
-
- if(AOP_TYPE(IC_RESULT(ic)) != AOP_ACC) {
-
- if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
- emitpcode(POC_ANDLW , popGetLit(1));
- emitpcode(POC_BCF , popGet(AOP(IC_RESULT(ic)),0));
- emitSKPZ;
- emitpcode(POC_BSF , popGet(AOP(IC_RESULT(ic)),0));
- } else {
- emitpcode(POC_MOVWF , popGet(AOP(IC_RESULT(ic)),0));
- pic14_emitcode("movwf","%s", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
- }
- }
- }
-
- } else {
- int offset = 1;
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
- emitCLRZ;
- emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0));
- emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),0));
-
- pic14_emitcode("clrz","");
-
- pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(IC_RIGHT(ic))->aopu.aop_dir,
- AOP(IC_RIGHT(ic))->aopu.aop_dir);
- pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-
- } else {
-
- emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),0));
- emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0));
- emitpcode(POC_INCFW, popGet(AOP(IC_LEFT(ic)),0));
- //emitpcode(POC_MOVWF, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
- emitMOVWF(IC_RIGHT(ic),0);
-
- pic14_emitcode("movf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(IC_RIGHT(ic))->aopu.aop_dir,
- AOP(IC_RIGHT(ic))->aopu.aop_dir);
- pic14_emitcode(" incf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- pic14_emitcode("movwf","%s", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-
- }
-
- while(--size){
- emitSKPZ;
- emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),offset++));
- //pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RIGHT(ic)),offset++,FALSE,FALSE));
- }
-
- }
-
- } else {
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
-
- /* Add the first bytes */
-
- if(strcmp(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE),"a") == 0 ) {
- emitpcode(POC_ADDFW, popGet(AOP(IC_RIGHT(ic)),0));
- emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0));
- } else {
-
- if ( AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
- emitpcode(POC_ADDFW, popGet(AOP(IC_RIGHT(ic)),0));
- if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
- emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0));
- } else {
-
- emitpcode(POC_MOVFW,popGet(AOP(IC_RIGHT(ic)),0));
-
- if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
- emitpcode(POC_ADDWF, popGet(AOP(IC_LEFT(ic)),0));
- else {
- PIC_OPCODE poc = POC_ADDFW;
-
- if ((AOP_TYPE(IC_LEFT(ic)) == AOP_PCODE) && (
- (AOP(IC_LEFT(ic))->aopu.pcop->type == PO_LITERAL) ||
- (AOP(IC_LEFT(ic))->aopu.pcop->type == PO_IMMEDIATE)))
- poc = POC_ADDLW;
- emitpcode(poc, popGet(AOP(IC_LEFT(ic)),0));
- if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
- emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0));
- }
- }
- }
-
- size = min( AOP_SIZE(IC_RESULT(ic)), AOP_SIZE(IC_RIGHT(ic))) - 1;
- offset = 1;
-
-
- while(size--){
- if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
- emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),offset));
- emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset));
-
- pic14_emitcode("movf","%s,w", aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
- pic14_emitcode("movwf","%s", aopGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
- }
-
- emitpcode(POC_MOVFW, popGet(AOP(IC_RIGHT(ic)),offset));
- emitSKPNC;
- emitpcode(POC_INCFSZW, popGet(AOP(IC_RIGHT(ic)),offset));
- emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),offset));
-
- /*
- pic14_emitcode("movf","%s,w", aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
- emitSKPNC;
- pic14_emitcode("incfsz","%s,w",aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
- pic14_emitcode("addwf","%s,f", aopGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
- */
-
- offset++;
- }
-
- }
-
- if (AOP_SIZE(IC_RESULT(ic)) > AOP_SIZE(IC_RIGHT(ic))) {
- int sign = !(SPEC_USIGN(getSpec(operandType(IC_LEFT(ic)))) |
- SPEC_USIGN(getSpec(operandType(IC_RIGHT(ic)))) );
-
-
- /* Need to extend result to higher bytes */
- size = AOP_SIZE(IC_RESULT(ic)) - AOP_SIZE(IC_RIGHT(ic)) - 1;
-
- /* First grab the carry from the lower bytes */
- emitpcode(POC_CLRF, popGet(AOP(IC_RESULT(ic)),offset));
- emitpcode(POC_RLF, popGet(AOP(IC_RESULT(ic)),offset));
-
-
- if(sign) {
- /* Now this is really horrid. Gotta check the sign of the addends and propogate
- * to the result */
-
- emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(IC_LEFT(ic)),offset-1,FALSE,FALSE),7,0));
- emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),offset));
- emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(IC_RIGHT(ic)),offset-1,FALSE,FALSE),7,0));
- emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),offset));
-
- /* if chars or ints or being signed extended to longs: */
- if(size) {
- emitpcode(POC_MOVLW, popGetLit(0));
- emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE),7,0));
- emitpcode(POC_MOVLW, popGetLit(0xff));
- }
- }
-
- offset++;
- while(size--) {
-
- if(sign)
- emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset));
- else
- emitpcode(POC_CLRF, popGet(AOP(IC_RESULT(ic)),offset));
-
- offset++;
- }
- }
-
-
- //adjustArithmeticResult(ic);
-
- release:
- freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
- freeAsmop(IC_RIGHT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
- freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genMinusDec :- does subtraction with decrement if possible */
-/*-----------------------------------------------------------------*/
-bool genMinusDec (iCode *ic)
-{
- unsigned int icount ;
- unsigned int size = pic14_getDataSize(IC_RESULT(ic));
-
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- /* will try to generate an increment */
- /* if the right side is not a literal
- we cannot */
- if ((AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT) ||
- (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) ||
- (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) )
- return FALSE ;
-
- DEBUGpic14_emitcode ("; lit val","%d",(unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit));
-
- /* if the literal value of the right hand side
- is greater than 4 then it is not worth it */
- if ((icount = (unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 2)
- return FALSE ;
-
- /* if decrement 16 bits in register */
- if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) &&
- (size > 1) &&
- (icount == 1)) {
-
- if(size == 2) {
- emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),LSB));
- emitpcode(POC_INCFSZW, popGet(AOP(IC_RESULT(ic)),LSB));
- emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),MSB16));
- emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),MSB16));
-
- pic14_emitcode("decf","%s,f",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
- pic14_emitcode("incfsz","%s,w",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
- pic14_emitcode(" decf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
- } else {
- /* size is 3 or 4 */
- emitpcode(POC_MOVLW, popGetLit(0xff));
- emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),LSB));
- emitSKPNC;
- emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),MSB16));
- emitSKPNC;
- emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),MSB24));
-
- pic14_emitcode("movlw","0xff");
- pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
-
- emitSKPNC;
- pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
- emitSKPNC;
- pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE));
-
- if(size > 3) {
- emitSKPNC;
- emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),MSB32));
-
- pic14_emitcode("skpnc","");
- emitSKPNC;
- pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE));
- }
-
- }
-
- return TRUE;
-
- }
-
- /* if the sizes are greater than 1 then we cannot */
- if (AOP_SIZE(IC_RESULT(ic)) > 1 ||
- AOP_SIZE(IC_LEFT(ic)) > 1 )
- return FALSE ;
-
- /* we can if the aops of the left & result match or
- if they are in registers and the registers are the
- same */
- if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic)))) {
-
- while (icount--)
- emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),0));
-
- //pic14_emitcode ("decf","%s,f",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-
- return TRUE ;
- }
-
- DEBUGpic14_emitcode ("; returning"," result=%s, left=%s",
- aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE),
- aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- if(size==1) {
-
- pic14_emitcode("decf","%s,w",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
- pic14_emitcode("movwf","%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-
- emitpcode(POC_DECFW, popGet(AOP(IC_LEFT(ic)),0));
- emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),0));
-
- return TRUE;
- }
-
- return FALSE ;
+ int size, offset = 0;
+
+ /* special cases :- */
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ FENTRY;
+
+ aopOp (IC_LEFT(ic),ic,FALSE);
+ aopOp (IC_RIGHT(ic),ic,FALSE);
+ aopOp (IC_RESULT(ic),ic,TRUE);
+
+ DEBUGpic14_AopType(__LINE__,IC_LEFT(ic),IC_RIGHT(ic),IC_RESULT(ic));
+
+ /* if literal, literal on the right or
+ if left requires ACC or right is already
+ in ACC */
+
+ if (AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) {
+ operand *t = IC_RIGHT(ic);
+ IC_RIGHT(ic) = IC_LEFT(ic);
+ IC_LEFT(ic) = t;
+ }
+
+ /* if left in bit space & right literal */
+ if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
+ AOP_TYPE(IC_RIGHT(ic)) == AOP_LIT) {
+ /* if result in bit space */
+ if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){
+ if(ulFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit) != 0L) {
+ emitpcode(POC_MOVLW, popGet(AOP(IC_RESULT(ic)),0));
+ if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
+ emitpcode(POC_BTFSC, popGet(AOP(IC_LEFT(ic)),0));
+ emitpcode(POC_XORWF, popGet(AOP(IC_RESULT(ic)),0));
+ }
+ } else {
+ size = pic14_getDataSize(IC_RESULT(ic));
+ while (size--) {
+ MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
+ pic14_emitcode("addc","a,#00 ;%d",__LINE__);
+ aopPut(AOP(IC_RESULT(ic)),"a",offset++);
+ }
+ }
+ goto release ;
+ }
+
+ /* if I can do an increment instead
+ of add then GOOD for ME */
+ if (genPlusIncr (ic) == TRUE)
+ goto release;
+
+ size = pic14_getDataSize(IC_RESULT(ic));
+
+ if(AOP(IC_RIGHT(ic))->type == AOP_LIT) {
+ /* Add a literal to something else */
+ unsigned lit = (unsigned) ulFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit);
+ DEBUGpic14_emitcode(";","adding lit to something. size %d",size);
+
+ genAddLit (ic, lit);
+ goto release;
+
+ } else if(AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
+
+ pic14_emitcode(";bitadd","right is bit: %s",aopGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
+ pic14_emitcode(";bitadd","left is bit: %s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
+ pic14_emitcode(";bitadd","result is bit: %s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
+
+ /* here we are adding a bit to a char or int */
+ if(size == 1) {
+ if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
+ emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0));
+ emitpcode(POC_INCF , popGet(AOP(IC_RESULT(ic)),0));
+ } else {
+
+ emitpcode(POC_MOVFW , popGet(AOP(IC_LEFT(ic)),0));
+ emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0));
+ emitpcode(POC_INCFW , popGet(AOP(IC_LEFT(ic)),0));
+
+ if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
+ emitpcode(POC_ANDLW , popGetLit(1));
+ emitpcode(POC_BCF , popGet(AOP(IC_RESULT(ic)),0));
+ emitSKPZ;
+ emitpcode(POC_BSF , popGet(AOP(IC_RESULT(ic)),0));
+ } else {
+ emitpcode(POC_MOVWF , popGet(AOP(IC_RESULT(ic)),0));
+ }
+ }
+
+ } else {
+ int offset = 1;
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
+ emitCLRZ;
+ emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0));
+ emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),0));
+ } else {
+
+ emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),0));
+ emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0));
+ emitpcode(POC_INCFW, popGet(AOP(IC_LEFT(ic)),0));
+ emitMOVWF(IC_RIGHT(ic),0);
+ }
+
+ while(--size){
+ emitSKPZ;
+ emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),offset++));
+ }
+
+ }
+
+ } else {
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ /* Add the first bytes */
+
+ if(strcmp(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE),"a") == 0 ) {
+ emitpcode(POC_ADDFW, popGet(AOP(IC_RIGHT(ic)),0));
+ emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0));
+ } else {
+
+ emitpcode(POC_MOVFW,popGet(AOP(IC_RIGHT(ic)),0));
+
+ if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
+ emitpcode(POC_ADDWF, popGet(AOP(IC_LEFT(ic)),0));
+ else {
+ PIC_OPCODE poc = POC_ADDFW;
+
+ if (op_isLitLike (IC_LEFT (ic)))
+ poc = POC_ADDLW;
+ emitpcode(poc, popGetAddr(AOP(IC_LEFT(ic)),0,0));
+ emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0));
+ }
+ }
+
+ size = min( AOP_SIZE(IC_RESULT(ic)), AOP_SIZE(IC_RIGHT(ic))) - 1;
+ offset = 1;
+
+
+ if(size){
+ if (pic14_sameRegs(AOP(IC_RIGHT(ic)), AOP(IC_RESULT(ic)))) {
+ if (op_isLitLike (IC_LEFT(ic)))
+ {
+ while(size--){
+ emitpcode(POC_MOVFW, popGet(AOP(IC_RIGHT(ic)),offset));
+ emitSKPNC;
+ emitpcode(POC_INCFSZW, popGet(AOP(IC_RIGHT(ic)),offset));
+ emitpcode(POC_ADDLW, popGetAddr(AOP(IC_LEFT(ic)),offset,0));
+ emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset));
+ offset++;
+ }
+ } else {
+ while(size--){
+ emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),offset));
+ emitSKPNC;
+ emitpcode(POC_INCFSZW, popGet(AOP(IC_LEFT(ic)),offset));
+ emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),offset));
+ offset++;
+ }
+ }
+ } else {
+ PIC_OPCODE poc = POC_MOVFW;
+ if (op_isLitLike (IC_LEFT(ic)))
+ poc = POC_MOVLW;
+ while(size--){
+ if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
+ emitpcode(poc, popGetAddr(AOP(IC_LEFT(ic)),offset,0));
+ emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset));
+ }
+ emitpcode(POC_MOVFW, popGet(AOP(IC_RIGHT(ic)),offset));
+ emitSKPNC;
+ emitpcode(POC_INCFSZW, popGet(AOP(IC_RIGHT(ic)),offset));
+ emitpcode(POC_ADDWF, popGet(AOP(IC_RESULT(ic)),offset));
+ offset++;
+ }
+ }
+ }
+ }
+
+ if (AOP_SIZE(IC_RESULT(ic)) > AOP_SIZE(IC_RIGHT(ic))) {
+ int sign = !(SPEC_USIGN(getSpec(operandType(IC_LEFT(ic)))) |
+ SPEC_USIGN(getSpec(operandType(IC_RIGHT(ic)))) );
+
+
+ /* Need to extend result to higher bytes */
+ size = AOP_SIZE(IC_RESULT(ic)) - AOP_SIZE(IC_RIGHT(ic)) - 1;
+
+ /* First grab the carry from the lower bytes */
+ if (AOP_SIZE(IC_LEFT(ic)) > AOP_SIZE(IC_RIGHT(ic))) {
+ int leftsize = AOP_SIZE(IC_LEFT(ic)) - AOP_SIZE(IC_RIGHT(ic));
+ PIC_OPCODE poc = POC_MOVFW;
+ if (op_isLitLike (IC_LEFT(ic)))
+ poc = POC_MOVLW;
+ while(leftsize-- > 0) {
+ emitpcode(poc, popGetAddr(AOP(IC_LEFT(ic)),offset,0));
+ emitSKPNC;
+ emitpcode(POC_ADDLW, popGetLit(0x01));
+ emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset));
+ //emitSKPNC;
+ //emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),offset)); /* INCF does not update Carry! */
+ offset++;
+ if (size)
+ size--;
+ else
+ break;
+ }
+ } else {
+ emitpcode(POC_CLRF, popGet(AOP(IC_RESULT(ic)),offset));
+ emitpcode(POC_RLF, popGet(AOP(IC_RESULT(ic)),offset));
+ }
+
+
+ if(sign && offset > 0 && offset < AOP_SIZE(IC_RESULT(ic))) {
+ /* Now this is really horrid. Gotta check the sign of the addends and propogate
+ * to the result */
+
+ emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(IC_LEFT(ic)),offset-1,FALSE,FALSE),7,0));
+ emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),offset));
+ emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(IC_RIGHT(ic)),offset-1,FALSE,FALSE),7,0));
+ emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),offset));
+
+ /* if chars or ints or being signed extended to longs: */
+ if(size) {
+ emitpcode(POC_MOVLW, popGetLit(0));
+ emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE),7,0));
+ emitpcode(POC_MOVLW, popGetLit(0xff));
+ }
+ }
+
+ offset++;
+ while(size--) {
+
+ if(sign)
+ emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset));
+ else
+ emitpcode(POC_CLRF, popGet(AOP(IC_RESULT(ic)),offset));
+
+ offset++;
+ }
+ }
+
+
+ //adjustArithmeticResult(ic);
+
+release:
+ freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+ freeAsmop(IC_RIGHT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+ freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);