- } else if((PCI(pc1)->op == POC_MOVWF) && (PCI(pc2)->op == POC_MOVFW) ){
- //fprintf(stderr, " MOVWF/MOVFW. instruction after MOVFW is:\n");
- t = findNextInstruction(pc2->next);
- // t->print(stderr,t);
-
- if(PCI(t)->op == POC_MOVWF) {
- regs *nextreg = getRegFromInstruction(t);
- if(nextreg && !regUsedinRange(pc1,pc2,nextreg)) {
- t->seq = pc1->seq;
- unlinkpCode(t);
- pCodeInsertAfter(pc1,t);
+ } else if(PCI(pc1)->op == POC_MOVWF) {
+
+ pct2 = findNextInstruction(pc2->next);
+
+ if(PCI(pc2)->op == POC_MOVFW) {
+ //fprintf(stderr, " MOVWF/MOVFW. instruction after MOVFW is:\n");
+ // t->print(stderr,t);
+
+ if(PCI(pct2)->op == POC_MOVWF) {
+ reg2 = getRegFromInstruction(pct2);
+ if(reg2 && !regUsedinRange(pc1,pc2,reg2)) {
+ pct2->seq = pc1->seq;
+ unlinkpCode(pct2);
+ pCodeInsertAfter(pc1,pct2);
+ Remove2pcodes(pcfl_used, pc1, pc2, reg);
+ total_registers_saved++; // debugging stats.
+ continue;
+ }
+ }
+ }
+
+ pct1 = findPrevInstruction(pc1->prev);
+ if(pct1 &&
+ (PCI(pct1)->pcflow == PCI(pc1)->pcflow) &&
+ (PCI(pct1)->op == POC_MOVFW)) {
+
+ reg1 = getRegFromInstruction(pct1);
+ if(reg1 && !regUsedinRange(pc1,pc2,reg1)) {
+ /*
+ movf reg1,w
+ movwf reg
+
+ stuff...
+ opcode reg,w
+ */
+ pct2 = newpCode(PCI(pc2)->op, PCI(pct1)->pcop);
+ pCodeInsertAfter(pc2, pct2);
+ PCI(pct2)->pcflow = PCFL(pcfl_used);
+ pct2->seq = pc2->seq;
+