??? 01/20/08 17:47 Read: times |
#149774 - Your question Responding to: ???'s previous message |
Paul Blakey said:
So you haven't answered my question I answered this part of your question: is there a equal in C? Some 'C' compilers would be smart enough to spot that an 8-bit right-shift is equivalent to just taking the high byte; some might actually implement the shift. Shift-and-mask is the portable way to do it but, as above, may not be efficient; A union should be efficient, but is not portable. Either way, there is no need for inline assembler. BTW: some 8051 compilers can handle TH and TL as a single 16-bit SFR - I don't know SDCC, so you'll have to check the Manuals to see if it can and, if so, how. If supported, this is likely to be the most efficient way - but, of course, not portable. As for 2's complement - just use the "minus" operator! |
Topic | Author | Date |
SDCC, copying integer in ASM | 01/01/70 00:00 | |
Shift-and-mask, or union | 01/01/70 00:00 | |
I used asm tag and the rr command but.... | 01/01/70 00:00 | |
Your question | 01/01/70 00:00 | |
Portable unions | 01/01/70 00:00 | |
Less non-portable? | 01/01/70 00:00 | |
Less non-portable | 01/01/70 00:00 | |
portable, schmortable | 01/01/70 00:00 | |
Disagree! | 01/01/70 00:00 | |
how portable? | 01/01/70 00:00 | |
emphasis | 01/01/70 00:00 | |
Real world portable![]() | 01/01/70 00:00 | |
using - does not give the same result | 01/01/70 00:00 | |
try this | 01/01/70 00:00 | |
You are exceeeding 2 byte signed integer limits | 01/01/70 00:00 | |
Fighting the tools | 01/01/70 00:00 | |
Thanks all. | 01/01/70 00:00 | |
Dangerous | 01/01/70 00:00 | |
Very important warning! | 01/01/70 00:00 |