diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-05-17 22:59:55 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-05-17 22:59:55 (GMT) |
commit | 4d0ff0c23862c242d533d9b2d34e8812ef99ad61 (patch) | |
tree | 3b8504b8d3946a8bc9a702b819138ab1e5501be6 /src/common | |
parent | 96cb6971ee3ca529958b8cb1e8e55a6eb4e60eae (diff) |
Used only the new format of processor/instructions/operands for x86.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@64 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common')
-rwxr-xr-x | src/common/endianness.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/common/endianness.c b/src/common/endianness.c index 17ee252..059295d 100755 --- a/src/common/endianness.c +++ b/src/common/endianness.c @@ -133,20 +133,37 @@ bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, Source switch (endian) { + case SRE_LITTLE: +#if __BYTE_ORDER == __LITTLE_ENDIAN + + *target = data[*pos] | (uint32_t)data[*pos + 1] << 8; + *target |= data[*pos + 2] << 16 | (uint32_t)data[*pos + 3] << 24; + +#elif __BYTE_ORDER == __BIG_ENDIAN + *target = data[*pos + 3] | (uint32_t)data[*pos + 2] << 8; + *target |= data[*pos + 1] << 16 | (uint32_t)data[*pos] << 24; + +#else + +# error "TODO : PDP !" + +#endif + + break; case SRE_BIG: #if __BYTE_ORDER == __LITTLE_ENDIAN - *target = data[*pos + 3] | (uint16_t)data[*pos + 2] << 8; - *target |= data[*pos + 1] << 16 | (uint16_t)data[*pos] << 24; + *target = data[*pos + 3] | (uint32_t)data[*pos + 2] << 8; + *target |= data[*pos + 1] << 16 | (uint32_t)data[*pos] << 24; #elif __BYTE_ORDER == __BIG_ENDIAN - *target = data[*pos] | (uint16_t)data[*pos + 1] << 8; - *target |= data[*pos + 2] << 16 | (uint16_t)data[*pos + 3] << 24; + *target = data[*pos] | (uint32_t)data[*pos + 1] << 8; + *target |= data[*pos + 2] << 16 | (uint32_t)data[*pos + 3] << 24; #else |