At 08:00 AM 3/6/97 PST, you wrote: >Hi, > >I think I'm missing something very basic. I'm using ByteCraft's MPC and >the target controller is the PIC16C74A. This macro is supposed to take >2 unsigned 8-bit chars (h: high, l: low), concatenate them, and return >the unsigned 16 bit result. Instead, it's masking (zeroing) the high >byte. > >#define WORD(h,l) (((unsigned long)(h) << 8) | (unsigned char)(l)) > >Thanks, Matt > I don't use the MPC compiler, but have you tried: - extra brackets around the first cast & the "(h)", like this: #define WORD(h,l) ((((unsigned long)(h)) << 8) | (unsigned char)(l)) - using a different cast like (uint16) or (word), to see if the compiler is only allowing 8 bits for the "long". - casting the whole macro to ensure a 16 bit output: #define WORD(h,l) (unsigned long)(((unsigned long)(h) << 8) | \ (unsigned char)(l)) IMHO, it seems there should be a much more efficient way to create a word out of two bytes than this. I'm curious as heck what the compiler gives you for that macro. Maybe it actually sets up a loop and shifts eight times (gross!). Trouble is, I can't think of any alternatives right now. Anyone got ideas? -Ed V.