Hello all,
If I have a C-like data structure such that
struct Data {
int a; //16-bit value
char[3]; //3 ASCII characters
int b; //32-bit value
int c; //24-bit value
}
then assuming I were to store this on a 32 bit wide byte addressable
memory,
then, say, if a= 0A 0B, b=43 44 45, c= 80 00 00 44 and d = 123 (all in
hex), then would I be correct in saying that in a big endian
architecture it
would be stored like the following:
Address 0: 0A 0B 43 44
Address 1: 45 80 00 00
Address 2: 44 00 01 23
and in a little endian:
Address 0: 0B 0A 43 44
Address 1: 45 44 00 00
Address 2: 80 23 01 00
??
I assume this is correct but would appreciate a check nonetheless.
What I wanted to know was if I were to copy
byte by byte (in the more probable scenario you have described) from
the
little endian architecture to the big endian architecture would I end
up
with the same ordering as in the big endian and therefore need to swap
bytes? In other words, if my little endian architecture stores data in
the
following form:
Address 0: 0B 0A 43 44
Address 1: 45 44 00 00
Address 2: 80 23 01 00
and I were to copy this byte by byte to a big endian architecture is
this
what I would end up with:
Address 0: 0B 0A 43 44
Address 1: 45 44 00 00
Address 2: 80 23 01 00
??
or would it look completely different?
What if instead of copying byte by byte I were to copy word by word
(i.e. an
entire address at the time) would I still end up with the same result?
Thanks in anticipation