Skip to content

Commit

Permalink
Fix LOADU8
Browse files Browse the repository at this point in the history
It was generating wrong results
  • Loading branch information
Hasekawa-Takumi committed Apr 21, 2024
1 parent 0a1b859 commit 5fc8ad0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,16 @@ where
// The array index of the word for the byte to read from
let index_of_read = index_of_byte(read_addr.into());
// The byte from the read cell.
let cell_byte = cell[index_of_read];
let cell_byte: u8 = cell[index_of_read];

let write_addr = (state.cpu().fp as i32 + ops.a()) as u32;
// The address, converted to a multiple of 4.
let write_addr_index = addr_of_word(write_addr);

// The Word to write, with one byte overwritten to the read byte
let cell_to_write = Word::zero_extend_byte(cell_byte);

state
.mem_mut()
.write(clk, write_addr_index, cell_to_write, true);
.write(clk, write_addr_index, Word::from_u8(cell_byte), true);
state.cpu_mut().pc += 1;
state.cpu_mut().push_op(Operation::LoadU8, opcode, ops);
}
Expand Down

0 comments on commit 5fc8ad0

Please sign in to comment.