/*-----------------------------------------------------------------*/
/* genUnpackBits - generates code for unpacking bits */
/*-----------------------------------------------------------------*/
-static void genUnpackBits (operand *result, char *rname, int ptype)
+static void genUnpackBits (operand *result, operand *left, char *rname, int ptype)
{
int shCnt ;
int rlen = 0 ;
&& ((AOP(left)->aopu.pcop->type == PO_IMMEDIATE)
|| (AOP(left)->aopu.pcop->type == PO_DIR))) // patch 10
{
- pic16_loadFSR0( left ); // patch 10
+ if(!IS_BITFIELD(retype))
+ pic16_loadFSR0( left ); // patch 10
} else {
// set up FSR0 with address from left
pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),0), pic16_popCopyReg(&pic16_pc_fsr0l))); // patch 10
/* if bitfield then unpack the bits */
if (IS_BITFIELD(retype))
- genUnpackBits (result, NULL, POINTER);
+ genUnpackBits (result, left, NULL, POINTER);
else {
/* we have can just get the values */
int size = AOP_SIZE(result);
/* if bitfield then unpack the bits */
if (IS_BITFIELD(retype))
- genUnpackBits (result,rname,PPOINTER);
+ genUnpackBits (result,left,rname,PPOINTER);
else {
/* we have can just get the values */
int size = AOP_SIZE(result);
/* if bit then unpack */
if (IS_BITFIELD(retype))
- genUnpackBits(result,"dptr",FPOINTER);
+ genUnpackBits(result,left,"dptr",FPOINTER);
else {
size = AOP_SIZE(result);
offset = 0 ;
/* if bit then unpack */
if (IS_BITFIELD(retype))
- genUnpackBits(result,"dptr",CPOINTER);
+ genUnpackBits(result,left,"dptr",CPOINTER);
else {
size = AOP_SIZE(result);
offset = 0 ;
/* if bit then unpack */
if (IS_BITFIELD(retype))
- genUnpackBits(result,"BAD",GPOINTER);
+ genUnpackBits(result,left,"BAD",GPOINTER);
release:
pic16_freeAsmop(left,NULL,ic,TRUE);
/*-----------------------------------------------------------------*/
/* genPackBits - generates code for packed bit storage */
/*-----------------------------------------------------------------*/
-static void genPackBits (sym_link *etype ,
+static void genPackBits (sym_link *etype , operand *result,
operand *right ,
char *rname, int p_type)
{
lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
// pic16_emitpcode(POC_MOVFW, pic16_popCopyReg(&pic16_pc_indf0));
- if(lit) {
- pic16_emitpcode(POC_BSF,
- pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+ if((p_type == POINTER) && (result)) {
+ /* workaround to reduce the extra lfsr instruction */
+ if(lit) {
+ pic16_emitpcode(POC_BSF,
+ pic16_popCopyGPR2Bit(pic16_popGet(AOP(result), 0), bstr));
+ } else {
+ pic16_emitpcode(POC_BCF,
+ pic16_popCopyGPR2Bit(pic16_popGet(AOP(result), 0), bstr));
+ }
} else {
- pic16_emitpcode(POC_BCF,
- pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+
+ if(lit) {
+ pic16_emitpcode(POC_BSF,
+ pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+ } else {
+ pic16_emitpcode(POC_BCF,
+ pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+ }
}
return;
&& ((AOP(result)->aopu.pcop->type == PO_IMMEDIATE)
|| (AOP(result)->aopu.pcop->type == PO_DIR))) // patch 10
{
+ if(!IS_BITFIELD(resetype))
pic16_loadFSR0( result ); // patch 10
} else {
// set up FSR0 with address of result
/* if bitfield then unpack the bits */
if (IS_BITFIELD(resetype)) {
- genPackBits (resetype, right, NULL, POINTER);
+ genPackBits (resetype, result, right, NULL, POINTER);
} else {
/* we have can just get the values */
int size = AOP_SIZE(right);
/* if bitfield then unpack the bits */
if (IS_BITFIELD(retype))
- genPackBits (retype,right,rname,PPOINTER);
+ genPackBits (retype,result,right,rname,PPOINTER);
else {
/* we have can just get the values */
int size = AOP_SIZE(right);
/* if bit then unpack */
if (IS_BITFIELD(retype))
- genPackBits(retype,right,"dptr",FPOINTER);
+ genPackBits(retype,result,right,"dptr",FPOINTER);
else {
size = AOP_SIZE(right);
offset = 0 ;
/* if bit then unpack */
if (IS_BITFIELD(retype))
- genPackBits(retype,right,"dptr",GPOINTER);
+ genPackBits(retype,result,right,"dptr",GPOINTER);
else {
size = AOP_SIZE(right);
offset = 0 ;
if(AOP_TYPE(right) != AOP_LIT
&& IN_CODESPACE(SPEC_OCLS(OP_SYMBOL(right)->etype))) {
DEBUGpic16_emitcode("; ", "%s:%d symbol in code space, take special care\n", __FUNCTION__, __LINE__);
+ fprintf(stderr, "%s:%d symbol %s = [ %s ] is in code space\n", __FILE__, __LINE__, OP_SYMBOL(result)->name, OP_SYMBOL(right)->name);
// set up table pointer
if( (AOP_TYPE(right) == AOP_PCODE)
&& ((AOP(right)->aopu.pcop->type == PO_IMMEDIATE)
|| (AOP(right)->aopu.pcop->type == PO_DIR)))
{
+ fprintf(stderr, "%s:%d inside block 1\n", __FILE__, __LINE__);
pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),0));
pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptrl));
pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),1));
pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),2));
pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptru));
} else {
+ fprintf(stderr, "%s:%d inside block 2\n", __FILE__, __LINE__);
pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(right),0),
pic16_popCopyReg(&pic16_pc_tblptrl)));
pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(right),1),
#define NO_DEFLIBS "--nodefaultlibs"
#define MPLAB_COMPAT "--mplab-comp"
+#define NL_OPT "--nl="
+
char *alt_asm=NULL;
char *alt_link=NULL;
int pic16_fstack=0;
int pic16_enable_peeps=0;
+int pic16_nl=0; /* 0 for LF, 1 for CRLF */
OPTION pic16_optionsTable[]= {
{ 0, NO_DEFLIBS, &pic16_options.nodefaultlibs, "do not link default libraries when linking"},
{ 0, "--pomit-config-words", &pic16_options.omit_configw, "omit the generation of configuration words"},
{ 0, "--pomit-ivt", &pic16_options.omit_ivt, "omit the generation of the Interrupt Vector Table"},
{ 0, "--pleave-reset-vector",&pic16_options.leave_reset, "when omitting IVT leave RESET vector"},
- { 0, STACK_MODEL, NULL, "use stack model 'small' (default) or 'large'"},
+ { 0, STACK_MODEL, NULL, "use stack model 'small' (default) or 'large'"},
{ 0, "--debug-xtra", &pic16_debug_verbose, "show more debug info in assembly output"},
{ 0, "--debug-ralloc", &pic16_ralloc_debug, "dump register allocator debug file *.d"},
{ 0, "--calltree", &pic16_options.dumpcalltree, "dump call tree in .calltree file"},
{ 0, MPLAB_COMPAT, &pic16_mplab_comp, "enable compatibility mode for MPLAB utilities (MPASM/MPLINK)"},
{ 0, "--fstack", &pic16_fstack, "enable stack optimizations"},
+ { 0, NL_OPT, NULL, "new line, \"lf\" or \"crlf\""},
{ 0, NULL, NULL, NULL}
};
if(ISOPT(STACK_MODEL)) {
stkmodel = getStringArg(STACK_MODEL, argv, i, *pargc);
- if(STRCASECMP(stkmodel, "small"))pic16_options.stack_model = 0;
- else if(STRCASECMP(stkmodel, "large"))pic16_options.stack_model = 1;
+ if(!STRCASECMP(stkmodel, "small"))pic16_options.stack_model = 0;
+ else if(!STRCASECMP(stkmodel, "large"))pic16_options.stack_model = 1;
else {
fprintf(stderr, "Unknown stack model: %s", stkmodel);
exit(-1);
pic16_options.ivt_loc = getIntArg(IVT_LOC, argv, i, *pargc);
return TRUE;
}
-
+
+ if(ISOPT(NL_OPT)) {
+ char *tmp;
+
+ tmp = Safe_strdup( getStringArg(NL_OPT, argv, i, *pargc) );
+ if(!STRCASECMP(tmp, "lf"))pic16_nl = 0;
+ else if(!STRCASECMP(tmp, "crlf"))pic16_nl = 1;
+ else {
+ fprintf(stderr, "invalid termination character id\n");
+ exit(-1);
+ }
+ return TRUE;
+ }
+
return FALSE;
}