I am an old assembly programmer and I am trying to teach myself c programming.
I have a function that converts a 32 bit value for endianess and I can't figure out why I do not the the corrected value returned.
This is part of my code
This is my functionCode:int process_cmd(int sock) { int cmd, ccmd, res; int (* process_func)(int); RECV_INTEGER(&cmd); ccmd=cmd; BYTESWAP2(ccmd); printf("converted %08X\n", ccmd);
The function input is 0158DA00 and should return 00DA5801 and yet itCode:int BYTESWAP2(ccmd) { return (((ccmd&0x000000FF)<<24)+((ccmd&0x0000FF00)<<8)+ ((ccmd&0x00FF0000)>>8)+((ccmd&0xFF000000)>>24)); }
after the function ccmd = 0158DA00
What am I doing wrong ?



LinkBack URL
About LinkBacks



