Hi All, This is related to my previous post, "Efficiently combining bytes into a long int". I'd like to find an efficient way to do this. My current implementation (below) results in (unnecessary) calls to the library function for shifting a long int.
sendLong(unsigned long out_data); { sendByte((unsigned char)(out_data >> 24)); sendByte((unsigned char)(out_data >> 16)); sendByte((unsigned char)(out_data >> 8)); sendByte((unsigned char)(out_data)); }
union LONGBYTES { uchar b[4]; ulong l; }; void sendLong(unsigned long out_data) { union LONGBYTES temp; temp.l = out_data; sendByte(temp.b[0]); sendByte(temp.b[1]); sendByte(temp.b[2]); sendByte(temp.b[3]); }
; FUNCTION _sendLong (BEGIN) ; SOURCE LINE # 349 ;---- Variable 'out_data' assigned to Register 'R4/R5/R6/R7' ---- ; SOURCE LINE # 350 ; SOURCE LINE # 352 R MOV temp+03H,R7 R MOV temp+02H,R6 R MOV temp+01H,R5 R MOV temp,R4 ; SOURCE LINE # 353 R MOV R7,temp E CALL _sendByte ; SOURCE LINE # 354 R MOV R7,temp+01H E CALL _sendByte ; SOURCE LINE # 355 R MOV R7,temp+02H E CALL _sendByte ; SOURCE LINE # 356 R MOV R7,temp+03H E CALL _sendByte ; FUNCTION _sendLong (END)