Jump to content
Sign in to follow this  
andydavy

C2cplus - Compiler Error For Shifting

Recommended Posts

IDE version: SourceBoost IDE version 5.6.1

Compiler: C2C-plus

Compiler version: 5.6.1e

Target device: PIC12F675

OS: WinXP

 

********* 1st problem **************

char state;

.

.

ledregisterbuffer >>= state;

 

Error output:-

default.c(237): Error: The second operand in shift expression must be a number

 

Comment:-

Why is it not possible to use a variable? It should work!!!

 

To get around this I used a switch statement as follows (not ideal):-

switch (state)

{

case 0:

ledregisterbuffer >>=0;

break;

case 1:

ledregisterbuffer >>=1;

.

.

.etc.

 

Although this compiles the assembler code produced for the

ledregisterbuffer >>=0; line actually just clears ledregisterbuffer.

(ie a right shift clears variable)

 

Assembler Below:-

 

;;;;;;;; switch (state)

movf _state, W

movwf _intr_tmp_0000

;;;;;;;; {

;;;;;;;; case 0:

movf _intr_tmp_0000 , W

sublw D'0'

btfss STATUS, Z

goto label_0027

;;;;;;;; ledregisterbuffer >>=0;

label_0028

andlw D'255'

movwf _ledregisterbuffer

;;;;;;;; break;

goto label_0026

;;;;;;;; case 1:

label_0027

movf _intr_tmp_0000 , W

sublw D'1'

btfss STATUS, Z

goto label_0029

 

break;

Share this post


Link to post
Share on other sites

Shift operation in C2C is mapped to shoft assembly instruction and as result the number of shifts must be represented by a constant. If you replace 'stat' with a const it will compile. BoostC compiler does not have such limitations.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

I would be happy to use BoostC, but I was compiling for the 12F675 which I don't beleive is supported by BoostC.

The 12F675 is the same as 12F629 but with 4 channel analogue input. Is there a way to get BoostC to compile for the 12F675??

 

Also, which is the better compiler C2Cplus or BoostC?

 

Thanks

 

Andy

Share this post


Link to post
Share on other sites

AndDavy,

 

Also, which is the better compiler C2Cplus or BoostC?

 

C2C-plus is a mature product, but it does have its limitations (such as the one you have just found).

 

SourceBoostC is much better, but it is still at the alpha release stage. So its not 100% perfect yet <_<

 

Currently SourceBoostC doesn't support 12F675 or 12F629. But these devices have the same core as the PIC16 devices, so it would be relatively easy to add these devices to compiler and linker, so I'm sure this will happen soon if there is a demand for it.

 

 

Regards

Dave

Share this post


Link to post
Share on other sites
Currently SourceBoostC doesn't support 12F675 or 12F629. But these devices have the same core as the PIC16 devices, so it would be relatively easy to add these devices to compiler and linker, so I'm sure this will happen soon if there is a demand for it.

 

Tha latest SourceBoost 5.7 release reads the list of supported targets from map.txt file that is in the config directory. Now adding support for a new targed for BoostC toolsuit is a matter of adding a configuration file (.TDF) for such target and adding it to map.txt (of course target must be either 14 or 16 bit core).

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...