share code between little and big endian; new implementation supports enum
remove old endianness code and use new implementation everywhere; do not test negative enum values anymore because a enum can be unsigned