CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Real problem by uchar or int8

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Franz
Guest







Real problem by uchar or int8
PostPosted: Thu Apr 08, 2004 4:32 am     Reply with quote

Hello my problems is : Can I do a shift 24 (>> 24) by ulong byte (int32) in a uchar.


If I write:


void tipol ( ulong misura, uchar offset )
{
uchar var ;

var = 0xff&(misura >> 24) ;
............

Can i do it in a uchar?

............
Is the code correct?
Thanks in advance.
Sorry for my bad english.
Ttelmah
Guest







Re: Real problem by uchar or int8
PostPosted: Thu Apr 08, 2004 5:04 am     Reply with quote

Franz wrote:
Hello my problems is : Can I do a shift 24 (>> 24) by ulong byte (int32) in a uchar.


If I write:


void tipol ( ulong misura, uchar offset )
{
uchar var ;

var = 0xff&(misura >> 24) ;
............

Can i do it in a uchar?

............
Is the code correct?
Thanks in advance.
Sorry for my bad english.

Yes. Since 'misura' is a 32bit value, the actual arithmetic will be done using 32bit arithmetic, and only converted at the end.
Potentially, there is a simpler instruction to get the same result:

var=make8(misura,3);

Will directly 'extract' the top byte of the 32bit value, more quickly (though the rotation should be automatically converted to a similar operation by the compilers optimisation, the 'mask' (using 0xff), will still be extra un-needed code.

Best Wishes
Franz
Guest







PostPosted: Wed Apr 14, 2004 9:11 am     Reply with quote

Thanks very much
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group