diff --git a/cli/cli.cpp b/cli/cli.cpp index e370343..19b2d7c 100644 --- a/cli/cli.cpp +++ b/cli/cli.cpp @@ -157,7 +157,8 @@ int main(int argc, char** argv) data_t data; data.resize(filesize + 2); - *(uint16_t*) &data[0] = filesize & 0xFFFFu; + data[0] = filesize & 0xFF; + data[1] = (filesize >> 8) & 0xFF; in.read((char*) &data[2], filesize); in.close(); diff --git a/src/TIVarFile.h b/src/TIVarFile.h index ed1439e..02e8760 100644 --- a/src/TIVarFile.h +++ b/src/TIVarFile.h @@ -116,7 +116,9 @@ namespace tivars // Extends BinaryFile. uint16_t get_two_bytes_swapped() { - return (this->get_raw_byte() & 0xFF) + (this->get_raw_byte() << 8); + uint8_t low = this->get_raw_byte(); + uint8_t high = this->get_raw_byte(); + return low + (high << 8); } var_header_t header;