Jump to content

Convert Ccs Shift_right/shift_left To Boostc?


Recommended Posts

C has two shift operator << and >>.

 

eg

 

x = y << 3; // y is left shifted 3 bits , the result is stored in x.

 

z = w >> t; // w is right shifted according to the contents of t, result stored in z

 

beware

wrong

y<<2;// y is shifted left two places but the result is not stored so y stays the same

correct

y = y << 2;

 

note that zeros are always shifted in, there is no arithmetic shift

 

You should consult a C manual for more detail

 

 

 

 

Hello,

 

How do I convert ccs shift_right()/shift_left() functions to boostc?

 

(I have seen some example code in this forum to convert to c2c, but that code doesn't compile in boostc)

 

Regards,

 

Marcel

Link to post
Share on other sites
this seems to work :

 

from ccs:

 

shift_right(&data,1,input(X10_TO_PIC));

 

to boostc :

 

data >>= 1;

    

if ((portb & X10_TO_PIC)==0)

   data &= 0x7F;      

else

   data |= 0x80;

Neater still:

#define X10_TO_PIC portb.0
...
...
data >>= 1;
data.7 = X10_TO_PIC;

 

Regards

Dave

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...
×
×
  • Create New...