>> eth_length = ((UI)workbuff[3] << 8) + (UI)workbuff[2]; >> >> eth_length = ((UI)workbuff[3] * 256) + (UI)workbuff[2];> That code should only take 4 instructions. How many instructions do > Hitech and CCS take? CCS compiles to 11 instructions (this is for an 18C452): (note that an 'int' in CCS is 8 bits; an 'int16' and a 'long' are 16 bits - I like the designation with the number of bits in it) typedef unsigned int16 UI; unsigned int16 eth_length; char workbuff[10]; eth_length = ((UI)workbuff[3] << 8) + (UI)workbuff[2]; CLRF 6D MOVFF 65,6C MOVFF 6C,6F CLRF 6E CLRF 03 MOVF 64,W ADDWF 6E,W MOVWF 60 MOVF 03,W ADDWFC 6F,W MOVWF 61 with the variables assigned as follows by the compiler: eth_length: 60-61 workbuff: 62-6B compiler scratch: 03, 6C-6F Both of the above statements compile identically. Of course, if I were pressed for code size, I would further eschew portability and use CCS's VERY handy #byte directive: unsigned int16 eth_length; #byte eth_lo = eth_length #byte eth_hi = eth_length + 1 char workbuff[10]; // eth_length = ((UI)workbuff[3] << 8) + (UI)workbuff[2]; // is the same as: eth_lo = workbuff[2]; eth_hi = workbuff[3]; which compiles to 2 instructions: MOVFF 64,60 MOVFF 65,61 Since this takes advantage of the movff instruction in the 18, I checked all of the above with a 16F876 (which means an older version of CCS's compiler - 2.708 - instead of v3.053 used for the 18 series stuff - so I don't know if that's a 'fair' comparison): eth_length = ((UI)workbuff[3] << 8) + (UI)workbuff[2]; 15 instructions eth_length = ((UI)workbuff[3] * 256) + (UI)workbuff[2]; 47 instructions! with #byte's: 4 instructions this is with these instructions as the only ones being compiled, which optimizes bank switching. For the 18 series, I just tossed these statements into the middle of a larger project I'm working on - when I did that with the 16 series, there were bsf 3,6 and bcf 3,6 scattered throughout. Just goes to show it ALWAYS pays to look at the code the compiler is generating - just directing the compiler where to put variables can have an effect on non-18 code. -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics