Skip to content

Commit 2925d97

Browse files
committed
Fixes reading two bytes.
1 parent d6211cf commit 2925d97

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,10 @@ impl VM {
294294
Opcode::JMP(address) => self.ip = address as usize - 1,
295295
Opcode::PR => print!("{}", self.memory[self.dp] as u8 as char),
296296
Opcode::RE => {
297-
let mut buffer = [0; 2];
297+
let mut buffer = [0; 1];
298298
std::io::Read::read_exact(&mut std::io::stdin(), &mut buffer)
299299
.expect("Failed to read input");
300300
self.memory[self.dp] = buffer[0] as i32;
301-
if self.dp + 1 < self.memory.len() {
302-
self.memory[self.dp + 1] = buffer[1] as i32;
303-
}
304301
}
305302
Opcode::JZ(address) => {
306303
if self.memory[self.dp] == 0 {

0 commit comments

Comments
 (0)