- pb = newpCodeChain(NULL, 'W', newpCode(POC_MOVWF, newpCodeOpWild(0,pcp,newpCodeOp(NULL,PO_GPR_REGISTER))) );
- addpCode2pBlock( pb, newpCode(POC_MOVFW, newpCodeOpWild(0,pcp,newpCodeOp(NULL,PO_GPR_REGISTER))) );
-
- pcp->target = pb;
-
- pcp->replace = newpCodeChain(NULL, 'W',newpCode(POC_MOVWF, newpCodeOpWild(0,pcp,newpCodeOp(NULL,PO_GPR_REGISTER))) );
-
- /* Allocate space to store pointers to the wildcard variables */
- pcp->nvars = 1;
- pcp->vars = Safe_calloc(pcp->nvars, sizeof(char *));
- pcp->nwildpCodes = 0;
- pcp->wildpCodes = NULL;
-
- pcp->postFalseCond = PCC_Z;
- pcp->postTrueCond = PCC_NONE;
-
- fprintf(stderr,"Peep rule\nTarget:\n");
- printpCodeString(stderr,pcp->target->pcHead, 10);
- fprintf(stderr,"Replaced with:\n");
- printpCodeString(stderr,pcp->replace->pcHead, 10);
-
- /* Now for another peep example */
- pcps = Safe_calloc(1,sizeof(pCodePeepSnippets));
- pcp = pcps->peep = Safe_calloc(1,sizeof(pCodePeep));
- peepSnippets = DLL_append((_DLL*)peepSnippets,(_DLL*)pcps);
-
- {
- /*
- target:
-
- btfsc %0
- goto %1
- %3
- %1: %4
-
- replace:
- btfss %0
- %3
- %1: %4
-
- The %3 and %4 are wild opcodes. Since the opcodes
- are stored in a different array than the wild operands,
- they can have the same indices and not conflict. So
- below, the %3 is really a %0, %4 is a %1.
-
- */
- pCodeOp *pcl;
- pCodeOp *pcw;
- pCodeOp *pcwb;
-
- // Create a new wild operand subtyped as a bit
- pcwb = newpCodeOpWild(0,pcp,newpCodeOpBit(NULL,-1));
-
- // Create a
- pb = newpCodeChain(NULL, 'W',newpCode(POC_BTFSC,pcwb));
-
- pcl = newpCodeOpLabel(-1);
- pcw = newpCodeOpWild(1, pcp, pcl);
- addpCode2pBlock( pb, newpCode(POC_GOTO, pcw));
- addpCode2pBlock( pb, newpCodeWild(0,NULL,NULL));
- addpCode2pBlock( pb, newpCodeWild(1,NULL,pcw));
-
-
- pcp->target = pb;
-
- pb = newpCodeChain(NULL, 'W',newpCode(POC_BTFSS, pcwb));
- addpCode2pBlock( pb, newpCodeWild(0,NULL,NULL));
- addpCode2pBlock( pb, newpCodeWild(1,NULL,pcw));
-
- pcp->replace = pb;
-
- /* Allocate space to store pointers to the wildcard variables */
- pcp->nvars = 2;
- pcp->vars = Safe_calloc(pcp->nvars, sizeof(char *));
- pcp->nwildpCodes = 2;
- pcp->wildpCodes = Safe_calloc(pcp->nwildpCodes, sizeof(pCode *));
-
- pcp->postFalseCond = PCC_NONE;
- pcp->postTrueCond = PCC_NONE;
- }
-
-
-
-
-
-
-
-
-
-
- //-------------
-
- /* Now for another peep example */
- pcps = Safe_calloc(1,sizeof(pCodePeepSnippets));
- pcp = pcps->peep = Safe_calloc(1,sizeof(pCodePeep));
- peepSnippets = DLL_append((_DLL*)peepSnippets,(_DLL*)pcps);
-
- {
- pCodeOp *pcw;
-
- pcw = newpCodeOpWild(0,pcp,newpCodeOp(NULL,PO_GPR_REGISTER));
-
- pb = newpCodeChain(NULL, 'W', newpCode(POC_MOVWF, pcw));
- addpCode2pBlock( pb, newpCode(POC_MOVWF, pcw));
-
- pcp->target = pb;
-
- pb = newpCodeChain(NULL, 'W',newpCode(POC_MOVWF, pcw));
-
- pcp->replace = pb;
-
- /* Allocate space to store pointers to the wildcard variables */
- pcp->nvars = 1;
- pcp->vars = Safe_calloc(pcp->nvars, sizeof(char *));
- pcp->nwildpCodes = 0;
- pcp->wildpCodes = NULL;
-
- pcp->postFalseCond = PCC_NONE;
- pcp->postTrueCond = PCC_NONE;
- }
-
-
-
-#endif
-}