implemented basic endianness-aware read and write functionality