Converting integers to big endian.
Fabio Cevasco h3rald@h3rald.com
Tue, 17 Dec 2024 21:53:51 +0100
1 files changed,
7 insertions(+),
1 deletions(-)
jump to
M
src/vm.c
→
src/vm.c
@@ -295,7 +295,13 @@ }
(*bytecode)[*size] = HEX_OP_PUSHIN; *size += 1; // opcode encode_length(bytecode, size, sizeof(int32_t)); - memcpy(&(*bytecode)[*size], &value, sizeof(int32_t)); + //memcpy(&(*bytecode)[*size], &value, sizeof(int32_t)); + memcpy(&(*bytecode)[*size], (uint8_t[]){ + (value >> 24) & 0xFF, + (value >> 16) & 0xFF, + (value >> 8) & 0xFF, + value & 0xFF + }, 4); *size += sizeof(int32_t); return 0; }