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:
2024-04-28 20:57:41 +05:30
parent 7ca9f1b98b
commit 08c9726333
3 changed files with 10 additions and 71 deletions

View File

@@ -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