Fixed bug with converting (h)word to (h)word in terms of endian
While it helped with understanding to use unions as a safe way to access the underlying bits, this shift based mechanism actually makes more sense at a glance, particularly by utilising WORD_NTH_BYTE
This commit is contained in:
@@ -431,9 +431,9 @@ size_t prog_write_bytecode(prog_t program, byte_t *bytes, size_t size_bytes)
|
||||
if (size_bytes < PROG_HEADER_SIZE || prog_bytecode_size(program) < size_bytes)
|
||||
return 0;
|
||||
// Write program header i.e. the start and count
|
||||
word_t start = word_htobc(program.start_address);
|
||||
word_t start = word_byteswap(program.start_address);
|
||||
*(bytes++) = start;
|
||||
word_t count = word_htobc(program.count);
|
||||
word_t count = word_byteswap(program.count);
|
||||
*(bytes++) = count;
|
||||
|
||||
// Write instructions
|
||||
|
||||
Reference in New Issue
Block a user