What is the best code in CCS for the instruction x>>15?
Ttelmah Guest
Posted: Sun Aug 23, 2009 1:55 pm
Probably depends on how large the data is.
For 16bit data, it'd probably be faster to just perform a bit test, on the top bit, and just output the result of this (0/1).
For larger data types, you really have no choice but to use the shift.
Best Wishes
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
Posted: Mon Aug 24, 2009 12:36 am
Code:
unsigned int16 var;
unsigned int8 x;
var = 0x8000;
x = make8 ( var, 1);
if (x & 0x80) {
do something;
} else {
do something else;
}
also works is:
Code:
if (var & 0x8000) {
do something;
}
_________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D
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