Closed mheyer32 closed 10 months ago
not worth the effort. please use some asm instead.
#define MKWORD(hi,lo) \
asm ("swap %0" : "=r"(hi) : "r"(hi)); \
asm ("move.w %2,%0": "=r"(hi) : "r"(hi), "rm"(lo))
Fair enough. I was just surprised that this seemingly simple operation turned into relatively many instructions.
Fair enough. I was just surprised that this seemingly simple operation turned into relatively many instructions.
because the short's need an extension to int to apply shift and or.
For completeness sake, after lots of trial and error, I have no settled on:
static inline int makeDWORD(short hi, short lo)
{
int res;
__asm __volatile ("swap %0 \n"
"move.w %2,%0"
: "=&r"(res)
: "0"(hi), "g"(lo)
: "cc");
return res;
}
Feel free to critique, I'm really not well versed in GCC inline assembly
Consider: http://franke.ms/cex/z/oYqroh
The compiler will do a lot of extra work, while I was expecting to see just to swap the first argument and move.w the second argument into the lower word.