split PIC port gen.c pcodepeep.c into smaller files. Added structure support.
[fw/sdcc] / src / pic / genarith.c
1 /*-------------------------------------------------------------------------
2   genarith.c - source file for code generation - arithmetic 
3   
4   Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1998)
5          and -  Jean-Louis VERN.jlvern@writeme.com (1999)
6   Bug Fixes  -  Wojciech Stryjewski  wstryj1@tiger.lsu.edu (1999 v2.1.9a)
7   PIC port   -  Scott Dattalo scott@dattalo.com (2000)
8   
9   This program is free software; you can redistribute it and/or modify it
10   under the terms of the GNU General Public License as published by the
11   Free Software Foundation; either version 2, or (at your option) any
12   later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18   
19   You should have received a copy of the GNU General Public License
20   along with this program; if not, write to the Free Software
21   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22   
23   In other words, you are welcome to use, share and improve this program.
24   You are forbidden to forbid anyone else to use, share and improve
25   what you give them.   Help stamp out software-hoarding!
26   
27   Notes:
28   000123 mlh    Moved aopLiteral to SDCCglue.c to help the split
29                 Made everything static
30 -------------------------------------------------------------------------*/
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <ctype.h>
36 #include "SDCCglobl.h"
37 #include "newalloc.h"
38
39 #if defined(_MSC_VER)
40 #define __FUNCTION__            __FILE__
41 #endif
42
43 #ifdef HAVE_SYS_ISA_DEFS_H
44 #include <sys/isa_defs.h>
45 #else
46 #ifdef HAVE_ENDIAN_H
47 #include <endian.h>
48 #else
49 #if !defined(__BORLANDC__) && !defined(_MSC_VER)
50 #warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN"
51 #warning "If you running sdcc on an INTEL 80x86 Platform you are okay"
52 #endif
53 #endif
54 #endif
55
56 #include "common.h"
57 #include "SDCCpeeph.h"
58 #include "ralloc.h"
59 #include "pcode.h"
60 #include "gen.h"
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 /*-----------------------------------------------------------------*/
78 /* genPlusIncr :- does addition with increment if possible         */
79 /*-----------------------------------------------------------------*/
80 bool genPlusIncr (iCode *ic)
81 {
82     unsigned int icount ;
83     unsigned int size = pic14_getDataSize(IC_RESULT(ic));
84
85     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
86     DEBUGpic14_emitcode ("; ","result %d, left %d, right %d",
87                    AOP_TYPE(IC_RESULT(ic)),
88                    AOP_TYPE(IC_LEFT(ic)),
89                    AOP_TYPE(IC_RIGHT(ic)));
90
91     /* will try to generate an increment */
92     /* if the right side is not a literal 
93        we cannot */
94     if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT)
95         return FALSE ;
96     
97     DEBUGpic14_emitcode ("; ","%s  %d",__FUNCTION__,__LINE__);
98     /* if the literal value of the right hand side
99        is greater than 1 then it is faster to add */
100     if ((icount =  floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 2)
101         return FALSE ;
102     
103     /* if increment 16 bits in register */
104     if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) &&
105         (icount == 1)) {
106
107       int offset = MSB16;
108
109       emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
110       //pic14_emitcode("incf","%s,f",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
111
112       while(--size) {
113         emitSKPNZ;
114         emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),offset++,FALSE,FALSE));
115         //pic14_emitcode(" incf","%s,f",aopGet(AOP(IC_RESULT(ic)),offset++,FALSE,FALSE));
116       }
117
118       return TRUE;
119     }
120     
121     DEBUGpic14_emitcode ("; ","%s  %d",__FUNCTION__,__LINE__);
122     /* if left is in accumulator  - probably a bit operation*/
123     if( strcmp(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE),"a")  &&
124         (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) ) {
125       
126       emitpcode(POC_BCF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
127       pic14_emitcode("bcf","(%s >> 3), (%s & 7)",
128                AOP(IC_RESULT(ic))->aopu.aop_dir,
129                AOP(IC_RESULT(ic))->aopu.aop_dir);
130       if(icount)
131         emitpcode(POC_XORLW,popGetLit(1));
132       //pic14_emitcode("xorlw","1");
133       else
134         emitpcode(POC_ANDLW,popGetLit(1));
135       //pic14_emitcode("andlw","1");
136
137       emitSKPZ;
138       emitpcode(POC_BSF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
139       pic14_emitcode("bsf","(%s >> 3), (%s & 7)",
140                AOP(IC_RESULT(ic))->aopu.aop_dir,
141                AOP(IC_RESULT(ic))->aopu.aop_dir);
142
143       return TRUE;
144     }
145
146
147
148     /* if the sizes are greater than 1 then we cannot */
149     if (AOP_SIZE(IC_RESULT(ic)) > 1 ||
150         AOP_SIZE(IC_LEFT(ic)) > 1   )
151         return FALSE ;
152     
153     /* If we are incrementing the same register by two: */
154
155     if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
156         
157       while (icount--) 
158         emitpcode(POC_INCF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
159       //pic14_emitcode("incf","%s,f",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
160         
161       return TRUE ;
162     }
163     
164     DEBUGpic14_emitcode ("; ","couldn't increment result-%s  left-%s",
165                    aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE),
166                    aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
167     return FALSE ;
168 }
169
170 /*-----------------------------------------------------------------*/
171 /* pic14_outBitAcc - output a bit in acc                                 */
172 /*-----------------------------------------------------------------*/
173 void pic14_outBitAcc(operand *result)
174 {
175     symbol *tlbl = newiTempLabel(NULL);
176     /* if the result is a bit */
177     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
178
179     if (AOP_TYPE(result) == AOP_CRY){
180         aopPut(AOP(result),"a",0);
181     }
182     else {
183         pic14_emitcode("jz","%05d_DS_",tlbl->key+100);
184         pic14_emitcode("mov","a,#01");
185         pic14_emitcode("","%05d_DS_:",tlbl->key+100);
186         pic14_outAcc(result);
187     }
188 }
189
190 /*-----------------------------------------------------------------*/
191 /* genPlusBits - generates code for addition of two bits           */
192 /*-----------------------------------------------------------------*/
193 void genPlusBits (iCode *ic)
194 {
195
196     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
197     /*
198       The following block of code will add two bits. 
199       Note that it'll even work if the destination is
200       the carry (C in the status register).
201       It won't work if the 'Z' bit is a source or destination.
202     */
203
204     /* If the result is stored in the accumulator (w) */
205     //if(strcmp(aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE),"a") == 0 ) {
206     if(AOP_TYPE(IC_RESULT(ic)) != AOP_ACC) {
207       //emitpcode(  ( ((int) operandLitValue(right)) ? POC_BSF : POC_BCF),
208       //              popGet(AOP(result),0,FALSE,FALSE));
209
210       emitpcode(POC_MOVLW, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
211       emitpcode(POC_BCF,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
212       emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
213       emitpcode(POC_XORWF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
214       emitpcode(POC_BTFSC, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
215       emitpcode(POC_XORWF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
216
217         pic14_emitcode("movlw","(1 << (%s & 7))",
218                  AOP(IC_RESULT(ic))->aopu.aop_dir,
219                  AOP(IC_RESULT(ic))->aopu.aop_dir);
220         pic14_emitcode("bcf","(%s >> 3), (%s & 7)",
221                  AOP(IC_RESULT(ic))->aopu.aop_dir,
222                  AOP(IC_RESULT(ic))->aopu.aop_dir);
223         pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
224                  AOP(IC_RIGHT(ic))->aopu.aop_dir,
225                  AOP(IC_RIGHT(ic))->aopu.aop_dir);
226         pic14_emitcode("xorwf","(%s >>3),f",
227                  AOP(IC_RESULT(ic))->aopu.aop_dir);
228         pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
229                  AOP(IC_LEFT(ic))->aopu.aop_dir,
230                  AOP(IC_LEFT(ic))->aopu.aop_dir);
231         pic14_emitcode("xorwf","(%s>>3),f",
232                  AOP(IC_RESULT(ic))->aopu.aop_dir);
233     } else { 
234
235       emitpcode(POC_CLRW, NULL);
236       emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
237       emitpcode(POC_XORLW, popGetLit(1));
238       emitpcode(POC_BTFSC, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
239       emitpcode(POC_XORLW, popGetLit(1));
240
241       pic14_emitcode("clrw","");
242       pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
243                  AOP(IC_RIGHT(ic))->aopu.aop_dir,
244                  AOP(IC_RIGHT(ic))->aopu.aop_dir);
245       pic14_emitcode("xorlw","1");
246       pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
247                AOP(IC_LEFT(ic))->aopu.aop_dir,
248                AOP(IC_LEFT(ic))->aopu.aop_dir);
249       pic14_emitcode("xorlw","1");
250     }
251
252 }
253
254 #if 0
255 /* This is the original version of this code.
256  *
257  * This is being kept around for reference, 
258  * because I am not entirely sure I got it right...
259  */
260 static void adjustArithmeticResult(iCode *ic)
261 {
262     if (AOP_SIZE(IC_RESULT(ic)) == 3 && 
263         AOP_SIZE(IC_LEFT(ic)) == 3   &&
264         !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
265         aopPut(AOP(IC_RESULT(ic)),
266                aopGet(AOP(IC_LEFT(ic)),2,FALSE,FALSE),
267                2);
268
269     if (AOP_SIZE(IC_RESULT(ic)) == 3 && 
270         AOP_SIZE(IC_RIGHT(ic)) == 3   &&
271         !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
272         aopPut(AOP(IC_RESULT(ic)),
273                aopGet(AOP(IC_RIGHT(ic)),2,FALSE,FALSE),
274                2);
275     
276     if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
277         AOP_SIZE(IC_LEFT(ic)) < 3    &&
278         AOP_SIZE(IC_RIGHT(ic)) < 3   &&
279         !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) &&
280         !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) {
281         char buffer[5];
282         sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic)))));
283         aopPut(AOP(IC_RESULT(ic)),buffer,2);
284     }
285 }
286 //#else
287 /* This is the pure and virtuous version of this code.
288  * I'm pretty certain it's right, but not enough to toss the old 
289  * code just yet...
290  */
291 static void adjustArithmeticResult(iCode *ic)
292 {
293     if (opIsGptr(IC_RESULT(ic)) &&
294         opIsGptr(IC_LEFT(ic))   &&
295         !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
296     {
297         aopPut(AOP(IC_RESULT(ic)),
298                aopGet(AOP(IC_LEFT(ic)), GPTRSIZE - 1,FALSE,FALSE),
299                GPTRSIZE - 1);
300     }
301
302     if (opIsGptr(IC_RESULT(ic)) &&
303         opIsGptr(IC_RIGHT(ic))   &&
304         !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
305     {
306         aopPut(AOP(IC_RESULT(ic)),
307                aopGet(AOP(IC_RIGHT(ic)),GPTRSIZE - 1,FALSE,FALSE),
308                GPTRSIZE - 1);
309     }
310
311     if (opIsGptr(IC_RESULT(ic))            &&
312         AOP_SIZE(IC_LEFT(ic)) < GPTRSIZE   &&
313         AOP_SIZE(IC_RIGHT(ic)) < GPTRSIZE  &&
314          !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) &&
315          !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) {
316          char buffer[5];
317          sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic)))));
318          aopPut(AOP(IC_RESULT(ic)),buffer,GPTRSIZE - 1);
319      }
320 }
321 #endif
322
323 /*-----------------------------------------------------------------*/
324 /* genPlus - generates code for addition                           */
325 /*-----------------------------------------------------------------*/
326 void genPlus (iCode *ic)
327 {
328     int size, offset = 0;
329
330     /* special cases :- */
331     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
332
333     aopOp (IC_LEFT(ic),ic,FALSE);
334     aopOp (IC_RIGHT(ic),ic,FALSE);
335     aopOp (IC_RESULT(ic),ic,TRUE);
336
337     /* if literal, literal on the right or
338        if left requires ACC or right is already
339        in ACC */
340
341     if (AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) {
342         operand *t = IC_RIGHT(ic);
343         IC_RIGHT(ic) = IC_LEFT(ic);
344         IC_LEFT(ic) = t;
345     }
346
347     /* if both left & right are in bit space */
348     if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
349         AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
350         genPlusBits (ic);
351         goto release ;
352     }
353
354     /* if left in bit space & right literal */
355     if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
356         AOP_TYPE(IC_RIGHT(ic)) == AOP_LIT) {
357         /* if result in bit space */
358         if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){
359           if((unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit) != 0L) {
360             emitpcode(POC_MOVLW, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
361             if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
362               emitpcode(POC_BTFSC, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
363             emitpcode(POC_XORWF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
364           }
365         } else {
366             size = pic14_getDataSize(IC_RESULT(ic));
367             while (size--) {
368                 MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));  
369                 pic14_emitcode("addc","a,#00  ;%d",__LINE__);
370                 aopPut(AOP(IC_RESULT(ic)),"a",offset++);
371             }
372         }
373         goto release ;
374     }
375
376     /* if I can do an increment instead
377     of add then GOOD for ME */
378     if (genPlusIncr (ic) == TRUE)
379         goto release;   
380
381     size = pic14_getDataSize(IC_RESULT(ic));
382
383     if(AOP(IC_RIGHT(ic))->type == AOP_LIT) {
384       /* Add a literal to something else */
385       bool know_W=0;
386       unsigned lit = floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit);
387       unsigned l1=0;
388
389       offset = 0;
390       DEBUGpic14_emitcode(";","adding lit to something. size %d",size);
391       while(size--){
392
393       DEBUGpic14_emitcode(";","size %d",size);
394
395         switch (lit & 0xff) {
396         case 0:
397           break;
398         case 1:
399           if(pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))))
400             emitpcode(POC_INCF, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
401           else {
402             know_W = 0;
403             emitpcode(POC_INCFW, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
404             if(AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
405               emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
406           }
407           break;
408         case 0xff:
409           if(pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))))
410             emitpcode(POC_DECF, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
411           else {
412             know_W = 0;
413             emitpcode(POC_DECFW, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
414             if(AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
415               emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
416           }
417           break;
418         default:
419           if( !know_W || ( (lit&0xff) != l1)  ) {
420             know_W = 1;
421             emitpcode(POC_MOVLW,popGetLit(lit&0xff));
422           }
423           if(pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))))
424             emitpcode(POC_ADDWF, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
425           else {
426             know_W = 0;
427             emitpcode(POC_ADDFW, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
428             emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
429             if(size) {
430               emitSKPNC;
431               emitpcode(POC_INCF, popGet(AOP(IC_LEFT(ic)),offset+1,FALSE,FALSE));
432             }
433           }
434         }
435
436         l1 = lit & 0xff;
437         lit >>= 8;
438         offset++;
439       }
440
441     } else if(AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
442
443       pic14_emitcode(";bitadd","right is bit: %s",aopGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
444       pic14_emitcode(";bitadd","left is bit: %s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
445       pic14_emitcode(";bitadd","result is bit: %s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
446
447       /* here we are adding a bit to a char or int */
448       if(size == 1) {
449         if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
450
451           emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
452           emitpcode(POC_INCF ,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
453
454           pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
455                    AOP(IC_RIGHT(ic))->aopu.aop_dir,
456                    AOP(IC_RIGHT(ic))->aopu.aop_dir);
457           pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
458         } else {
459
460           if(AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
461             emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
462             emitpcode(POC_XORLW , popGetLit(1));
463
464             pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
465                      AOP(IC_RIGHT(ic))->aopu.aop_dir,
466                      AOP(IC_RIGHT(ic))->aopu.aop_dir);
467             pic14_emitcode(" xorlw","1");
468           } else {
469             emitpcode(POC_MOVFW , popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
470             emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
471             emitpcode(POC_INCFW , popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
472
473             pic14_emitcode("movf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
474             pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
475                      AOP(IC_RIGHT(ic))->aopu.aop_dir,
476                      AOP(IC_RIGHT(ic))->aopu.aop_dir);
477             pic14_emitcode(" incf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
478           }
479           
480           if(AOP_TYPE(IC_RESULT(ic)) != AOP_ACC) {
481             
482             if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
483               emitpcode(POC_ANDLW , popGetLit(1));
484               emitpcode(POC_BCF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
485               emitSKPZ;
486               emitpcode(POC_BSF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
487             } else {
488               emitpcode(POC_MOVWF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
489               pic14_emitcode("movwf","%s", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
490             }
491           }
492         }
493
494       } else {
495         int offset = 1;
496
497         if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
498           emitCLRZ;
499           emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
500           emitpcode(POC_INCF,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
501
502           pic14_emitcode("clrz","");
503
504           pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
505                    AOP(IC_RIGHT(ic))->aopu.aop_dir,
506                    AOP(IC_RIGHT(ic))->aopu.aop_dir);
507           pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
508
509         } else {
510
511           emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
512           emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
513           emitpcode(POC_INCFW, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
514           emitpcode(POC_MOVWF, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
515
516
517           pic14_emitcode("movf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
518           pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
519                    AOP(IC_RIGHT(ic))->aopu.aop_dir,
520                    AOP(IC_RIGHT(ic))->aopu.aop_dir);
521           pic14_emitcode(" incf","%s,w", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
522           pic14_emitcode("movwf","%s", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
523
524         }
525
526         while(--size){
527           emitSKPZ;
528           emitpcode(POC_INCF,  popGet(AOP(IC_RESULT(ic)),offset++,FALSE,FALSE));
529       //pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RIGHT(ic)),offset++,FALSE,FALSE));
530         }
531
532       }
533       
534     } else {
535     
536       if(strcmp(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE),"a") == 0 ) {
537         emitpcode(POC_ADDFW, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
538         emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
539       } else {
540
541         if ( AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
542           emitpcode(POC_ADDFW, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
543           if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
544             emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
545         } else {
546
547           emitpcode(POC_MOVFW,popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
548
549           if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
550             emitpcode(POC_ADDWF, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
551           else {
552             if( (AOP_TYPE(IC_LEFT(ic)) == AOP_IMMD) ||
553                 (AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) ) {
554               emitpcode(POC_ADDLW, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
555             } else {
556               emitpcode(POC_ADDFW, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
557               if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
558                 emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
559             }
560           }
561         }
562       }
563
564       offset = 1;
565       size--;
566
567       while(size--){
568         if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
569           emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
570           emitpcode(POC_MOVWF, popGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
571
572           pic14_emitcode("movf","%s,w",  aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
573           pic14_emitcode("movwf","%s",  aopGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
574         }
575
576         emitpcode(POC_MOVFW,   popGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
577         emitSKPNC;
578         emitpcode(POC_INCFSZW, popGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
579         emitpcode(POC_ADDWF,   popGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
580
581         /*
582         pic14_emitcode("movf","%s,w",  aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
583         emitSKPNC;
584         pic14_emitcode("incfsz","%s,w",aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
585         pic14_emitcode("addwf","%s,f", aopGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
586         */
587
588         offset++;
589       }
590
591     }
592
593     //adjustArithmeticResult(ic);
594
595  release:
596       freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
597       freeAsmop(IC_RIGHT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
598       freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
599 }
600
601 /*-----------------------------------------------------------------*/
602 /* genMinusDec :- does subtraction with decrement if possible     */
603 /*-----------------------------------------------------------------*/
604 bool genMinusDec (iCode *ic)
605 {
606     unsigned int icount ;
607     unsigned int size = pic14_getDataSize(IC_RESULT(ic));
608
609     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
610     /* will try to generate an increment */
611     /* if the right side is not a literal 
612     we cannot */
613     if ((AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT) || 
614         (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) || 
615         (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) )
616         return FALSE ;
617
618     DEBUGpic14_emitcode ("; lit val","%d",(unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit));
619
620     /* if the literal value of the right hand side
621     is greater than 4 then it is not worth it */
622     if ((icount = (unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 2)
623         return FALSE ;
624
625     /* if decrement 16 bits in register */
626     if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) &&
627         (size > 1) &&
628         (icount == 1)) {
629
630       if(size == 2) { 
631         emitpcode(POC_DECF,    popGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
632         emitpcode(POC_INCFSZW, popGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
633         emitpcode(POC_DECF,    popGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
634
635         pic14_emitcode("decf","%s,f",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
636         pic14_emitcode("incfsz","%s,w",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
637         pic14_emitcode(" decf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
638       } else {
639         /* size is 3 or 4 */
640         emitpcode(POC_MOVLW,  popGetLit(0xff));
641         emitpcode(POC_ADDWF,  popGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
642         emitSKPNC;
643         emitpcode(POC_ADDWF,  popGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
644         emitSKPNC;
645         emitpcode(POC_ADDWF,  popGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE));
646
647         pic14_emitcode("movlw","0xff");
648         pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
649
650         emitSKPNC;
651         pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
652         emitSKPNC;
653         pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE));
654
655         if(size > 3) {
656           emitSKPNC;
657           emitpcode(POC_ADDWF,  popGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE));
658
659           pic14_emitcode("skpnc","");
660           emitSKPNC;
661           pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE));
662         }
663
664       }
665
666       return TRUE;
667
668     }
669
670     /* if the sizes are greater than 1 then we cannot */
671     if (AOP_SIZE(IC_RESULT(ic)) > 1 ||
672         AOP_SIZE(IC_LEFT(ic)) > 1   )
673         return FALSE ;
674
675     /* we can if the aops of the left & result match or
676     if they are in registers and the registers are the
677     same */
678     if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic)))) {
679
680       while (icount--) 
681         emitpcode(POC_DECF, popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
682
683         //pic14_emitcode ("decf","%s,f",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
684
685         return TRUE ;
686     }
687
688     DEBUGpic14_emitcode ("; returning"," result=%s, left=%s",
689                    aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE),
690                    aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
691     if(size==1) {
692
693       pic14_emitcode("decf","%s,w",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
694       pic14_emitcode("movwf","%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
695
696       emitpcode(POC_DECFW,  popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
697       emitpcode(POC_MOVWF,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
698
699       return TRUE;
700     }
701
702     return FALSE ;
703 }
704
705 /*-----------------------------------------------------------------*/
706 /* addSign - complete with sign                                    */
707 /*-----------------------------------------------------------------*/
708 void addSign(operand *result, int offset, int sign)
709 {
710     int size = (pic14_getDataSize(result) - offset);
711     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
712     if(size > 0){
713         if(sign){
714             pic14_emitcode("rlc","a");
715             pic14_emitcode("subb","a,acc");
716             while(size--)
717                 aopPut(AOP(result),"a",offset++); 
718         } else
719             while(size--)
720                 aopPut(AOP(result),"#0",offset++);
721     }
722 }
723
724 /*-----------------------------------------------------------------*/
725 /* genMinusBits - generates code for subtraction  of two bits      */
726 /*-----------------------------------------------------------------*/
727 void genMinusBits (iCode *ic)
728 {
729     symbol *lbl = newiTempLabel(NULL);
730     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
731     if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){
732         pic14_emitcode("mov","c,%s",AOP(IC_LEFT(ic))->aopu.aop_dir);
733         pic14_emitcode("jnb","%s,%05d_DS_",AOP(IC_RIGHT(ic))->aopu.aop_dir,(lbl->key+100));
734         pic14_emitcode("cpl","c");
735         pic14_emitcode("","%05d_DS_:",(lbl->key+100));
736         pic14_outBitC(IC_RESULT(ic));
737     }
738     else{
739         pic14_emitcode("mov","c,%s",AOP(IC_RIGHT(ic))->aopu.aop_dir);
740         pic14_emitcode("subb","a,acc");
741         pic14_emitcode("jnb","%s,%05d_DS_",AOP(IC_LEFT(ic))->aopu.aop_dir,(lbl->key+100));
742         pic14_emitcode("inc","a");
743         pic14_emitcode("","%05d_DS_:",(lbl->key+100));
744         aopPut(AOP(IC_RESULT(ic)),"a",0);
745         addSign(IC_RESULT(ic), MSB16, SPEC_USIGN(getSpec(operandType(IC_RESULT(ic)))));
746     }
747 }
748
749 /*-----------------------------------------------------------------*/
750 /* genMinus - generates code for subtraction                       */
751 /*-----------------------------------------------------------------*/
752 void genMinus (iCode *ic)
753 {
754   int size, offset = 0;
755   unsigned long lit = 0L;
756
757   DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
758   aopOp (IC_LEFT(ic),ic,FALSE);
759   aopOp (IC_RIGHT(ic),ic,FALSE);
760   aopOp (IC_RESULT(ic),ic,TRUE);
761
762   if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY  &&
763       AOP_TYPE(IC_RIGHT(ic)) == AOP_LIT) {
764     operand *t = IC_RIGHT(ic);
765     IC_RIGHT(ic) = IC_LEFT(ic);
766     IC_LEFT(ic) = t;
767   }
768
769   /* special cases :- */
770   /* if both left & right are in bit space */
771   if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
772       AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
773     genPlusBits (ic);
774     goto release ;
775   }
776
777   /* if I can do an decrement instead
778      of subtract then GOOD for ME */
779   if (genMinusDec (ic) == TRUE)
780     goto release;   
781
782   size = pic14_getDataSize(IC_RESULT(ic));   
783
784   if(AOP(IC_RIGHT(ic))->type == AOP_LIT) {
785     /* Add a literal to something else */
786
787     lit = (unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit);
788     lit = - (long)lit;
789
790     /* add the first byte: */
791     pic14_emitcode("movlw","0x%x", lit & 0xff);
792     pic14_emitcode("addwf","%s,f", aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
793     emitpcode(POC_MOVLW,  popGetLit(lit & 0xff));
794     emitpcode(POC_ADDWF,  popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
795
796
797     offset = 1;
798     size--;
799
800     while(size-- > 0) {
801
802       lit >>= 8;
803
804       if(lit & 0xff) {
805
806         if((lit & 0xff) == 0xff) {
807           emitpcode(POC_MOVLW,  popGetLit(0xff));
808           emitSKPC;
809           emitpcode(POC_ADDWF,  popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
810         } else {
811           emitpcode(POC_MOVLW,  popGetLit(lit & 0xff));
812           emitSKPNC;
813           emitpcode(POC_MOVLW,  popGetLit((lit+1) & 0xff));
814           emitpcode(POC_ADDWF,  popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
815         }
816
817       } else {
818         /* do the rlf known zero trick here */
819         emitpcode(POC_MOVLW,  popGetLit(1));
820         emitSKPNC;
821         emitpcode(POC_ADDWF,  popGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
822       }
823       offset++;
824     }
825
826   } else if(AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
827     // bit subtraction
828
829     pic14_emitcode(";bitsub","right is bit: %s",aopGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
830     pic14_emitcode(";bitsub","left is bit: %s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
831     pic14_emitcode(";bitsub","result is bit: %s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
832
833     /* here we are subtracting a bit from a char or int */
834     if(size == 1) {
835       if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
836
837         emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
838         emitpcode(POC_DECF ,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
839
840         pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
841                  AOP(IC_RIGHT(ic))->aopu.aop_dir,
842                  AOP(IC_RIGHT(ic))->aopu.aop_dir);
843         pic14_emitcode(" incf","%s,f", aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
844       } else {
845
846         if(AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
847           emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
848           emitpcode(POC_XORLW , popGetLit(1));
849         }else  if( (AOP_TYPE(IC_LEFT(ic)) == AOP_IMMD) ||
850               (AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) ) {
851
852           lit = (unsigned long)floatFromVal(AOP(IC_LEFT(ic))->aopu.aop_lit);
853
854           if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
855             if (pic14_sameRegs(AOP(IC_RIGHT(ic)), AOP(IC_RESULT(ic))) ) {
856               if(lit & 1) {
857                 emitpcode(POC_MOVLW , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
858                 emitpcode(POC_XORWF , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
859               }
860             }else{
861               emitpcode(POC_BCF ,     popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
862               if(lit & 1) 
863                 emitpcode(POC_BTFSS , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
864               else
865                 emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
866               emitpcode(POC_BSF ,     popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
867             }
868             goto release;
869           } else {
870             emitpcode(POC_MOVLW , popGetLit(lit & 0xff));
871             emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
872             emitpcode(POC_MOVLW , popGetLit((lit-1) & 0xff));
873             emitpcode(POC_MOVWF , popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
874
875           }
876
877         } else {
878           emitpcode(POC_MOVFW , popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
879           emitpcode(POC_BTFSC , popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
880           emitpcode(POC_DECFW , popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
881         }
882           
883         if(AOP_TYPE(IC_RESULT(ic)) != AOP_ACC) {
884             
885           emitpcode(POC_MOVWF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
886
887         } else  {
888           emitpcode(POC_ANDLW , popGetLit(1));
889 /*
890           emitpcode(POC_BCF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
891           emitSKPZ;
892           emitpcode(POC_BSF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
893 */
894         }
895
896       }
897
898     }
899   } else {
900
901     if(strcmp(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE),"a") == 0 ) {
902       DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
903       emitpcode(POC_SUBFW, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
904       emitpcode(POC_SUBLW, popGetLit(0));
905       emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
906     } else {
907
908       if ( AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
909         emitpcode(POC_SUBFW, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
910         emitpcode(POC_SUBLW, popGetLit(0));
911         if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC)
912           emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
913       } else {
914
915         DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
916         if(AOP_TYPE(IC_RIGHT(ic)) != AOP_ACC) 
917           emitpcode(POC_MOVFW,popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
918
919         if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
920           emitpcode(POC_SUBWF, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
921         else {
922           if( (AOP_TYPE(IC_LEFT(ic)) == AOP_IMMD) ||
923               (AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) ) {
924             emitpcode(POC_SUBLW, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
925           } else {
926             emitpcode(POC_SUBFW, popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
927           }
928           if ( AOP_TYPE(IC_RESULT(ic)) != AOP_ACC) {
929             if ( AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
930               emitpcode(POC_BCF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
931               emitSKPZ;
932               emitpcode(POC_BSF ,   popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
933             }else
934               emitpcode(POC_MOVWF,popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
935           }
936         }
937       }
938     }
939
940     /*
941       emitpcode(POC_MOVFW,  popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
942
943       if (pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
944       emitpcode(POC_SUBFW,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
945       } else {
946       emitpcode(POC_SUBFW,  popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
947       emitpcode(POC_MOVWF,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
948       }
949     */
950     offset = 1;
951     size--;
952
953     while(size--){
954       if (!pic14_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
955         emitpcode(POC_MOVFW,  popGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
956         emitpcode(POC_MOVWF,  popGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
957       }
958       emitpcode(POC_MOVFW,  popGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
959       emitSKPNC;
960       emitpcode(POC_INCFSZW,popGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
961       emitpcode(POC_SUBWF,  popGet(AOP(IC_RESULT(ic)),offset,FALSE,FALSE));
962
963       offset++;
964     }
965
966   }
967
968
969   //    adjustArithmeticResult(ic);
970         
971  release:
972   freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
973   freeAsmop(IC_RIGHT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
974   freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
975 }
976
977