Skip to content

Commit

Permalink
Fix update_byte.
Browse files Browse the repository at this point in the history
  • Loading branch information
thealmarty committed Apr 30, 2024
1 parent 9cbb7a4 commit 9ff6d4e
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions machine/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ impl Word<u8> {
// The cell is stored in little endian format in the compiler. But the VM stores it in big endian.
impl Word<u8> {
pub fn update_byte(self, byte: u8, loc: usize) -> Self {
let result_little_end: [u8; MEMORY_CELL_BYTES] = self.0;
let mut result = [0; 4];
// Convert from little to big endian.
for i in 0..MEMORY_CELL_BYTES {
result[i] = result_little_end[3 - i];
}
let mut result = self.0;
result[loc] = byte;
Self(result)
}
Expand Down

0 comments on commit 9ff6d4e

Please sign in to comment.