Jump to content
Sign in to follow this  
james :-)

Error Unknown Symbol '?' - this has to be me...

Recommended Posts

Hi guys,

 

I'm trying to use the following I got from this forum to "reverse" a binary number.....

 

 

snip>

 

char swap_bits(char variable)

{

char temp;

temp = 0;

temp |= variable & 0x80 ? 0x01 ;

temp |= variable & 0x40 ? 0x02 ;

temp |= variable & 0x20 ? 0x04 ;

temp |= variable & 0x10 ? 0x08 ;

temp |= variable & 0x08 ? 0x10 ;

temp |= variable & 0x04 ? 0x20 ;

temp |= variable & 0x02 ? 0x40 ;

temp |= variable & 0x01 ? 0x80 ;

 

return temp;

}

 

but it won't compile I get the "Unknown Symbol" error.

 

It's got to be me but any ideas?

 

 

James :-)

Share this post


Link to post
Share on other sites

James, I have here the code I believe you are looking for that will give the best results and very little space.  I have been putting together libraries at this point and should be posting them in the near future.

 

char swap_bits(char variable)

{

#ifdef _SX

asm swap param00_swap_bits;

#endif

#ifdef _PIC

asm swapf param00_swap_bits;

#endif

return(variable);

}

 

 

 

This is the code tht it returns in sx mode, pic should be very comparable except it would use the swapf and no bank instruction most likely.

;;;;;;;;char swap_bits(char variable)

_swap_bits__code

;;;;;;;; {

;;;;;;;;

;;;;;;;; asm swap param00_swap_bits;

swap param00_swap_bits;

;;;;;;;;

;;;;;;;;

;;;;;;;;

;;;;;;;;

;;;;;;;; return(variable);

bank 010h

mov w, param00_swap_bits

retp

;;;;;;;; }

Share this post


Link to post
Share on other sites
Guest Dave

James,

 

.....

temp |= variable & 0x80 ? 0x01 ;

temp |= variable & 0x40 ? 0x02 ;

......

Two problems with the c-code option,

 

1) Use of the ? - should be w |= expression ? y:z;,

not w |= expression ? y;

 

2) ? operator not supported in C2C compiler.

 

Who posted such silly code ??? - oops it was me :(

 

Regards

Dave

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...