It is frequently required to obtain the highest order bit of an integral type (long, int, short or char types). SDCC recognizes the following expression to yield the highest order bit and generates optimized code for it, e.g.:
unsigned int gint;will generate the following code:
foo () {
unsigned char hob;
...
hob = (gint >> 15) & 1;
..
}
61 ; hob.c 7Variations of this case however will not be recognized. It is a standard C expression, so I heartily recommend this be the only way to get the highest order bit, (it is portable). Of course it will be recognized even if it is embedded in other expressions, e.g.:
000A E5*01 62 mov a,(_gint + 1)
000C 23 63 rl a
000D 54 01 64 anl a,#0x01
000F F5*02 65 mov _foo_hob_1_1,a
xyz = gint + ((gint >> 15) & 1);will still be recognized.