From ae6084e41bc0d3279ae038545c01322078e04ba5 Mon Sep 17 00:00:00 2001 From: darcy Date: Sat, 21 Sep 2024 15:28:09 +1000 Subject: [PATCH] Flush stdout after `PUTS` and `OUT` traps --- src/runtime.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime.rs b/src/runtime.rs index 9c94c78..dac69f4 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -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; @@ -273,6 +278,7 @@ impl RunState { 0x21 => { let chr = (*self.reg(0) & 0xFF) as u8 as char; print!("{chr}"); + stdout().flush().unwrap(); } // puts 0x22 => { @@ -289,6 +295,7 @@ impl RunState { addr += 1; } print!("{string}"); + stdout().flush().unwrap(); } // in 0x23 => {