Skip to content

Commit

Permalink
Merge pull request #39 from dxrcy/flush-stdout
Browse files Browse the repository at this point in the history
Flush stdout after `PUTS` and `OUT` traps
  • Loading branch information
rozukke authored Sep 21, 2024
2 parents b5d48f7 + ae6084e commit 6fc5c30
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use core::panic;
use std::{cmp::Ordering, i16, io::Write, u16, u32, u8, usize};
use std::{
cmp::Ordering,
i16,
io::{stdout, Write},
u16, u32, u8, usize,
};

use crate::Air;
use colored::Colorize;
Expand Down Expand Up @@ -273,6 +278,7 @@ impl RunState {
0x21 => {
let chr = (*self.reg(0) & 0xFF) as u8 as char;
print!("{chr}");
stdout().flush().unwrap();
}
// puts
0x22 => {
Expand All @@ -289,6 +295,7 @@ impl RunState {
addr += 1;
}
print!("{string}");
stdout().flush().unwrap();
}
// in
0x23 => {
Expand Down

0 comments on commit 6fc5c30

Please sign in to comment.