I was preparing to send some bits down a serial port and I did a very simple thing. The bits were defined in a long int like this: long int lngint=19114957L;
The hex representation of this string is, of course: 0123ABCD.
I then did some gyrations to cast this string into a char array so that I could send it down the port:
long int *liptr;
Things did not go as planned and after dumping the program, I found that the value stored in lngint, as as follows:
CD AB 23 01
The resulting character string of course, flew down the port backwards!
Clearly for this compiler/processor the highest addressed byte contains the most significant digits of the long int. Now-I can load the port_buffer array by hand, byte by byte, reversing the order. But this may not be a good idea. Perusing the few C books I have it appears that there is no standard as to how byte order for a long int is stored on a processor. I am using 186 platforms. Is the byte order conserved with other processors? I know that at least when dealing with discrete semiconductor components, bit ordering is not always consistent.