more work

This commit is contained in:
5225225 2020-06-06 22:11:43 +01:00
parent ad17d8f8b2
commit 92124b0efe
2 changed files with 6 additions and 5 deletions

Binary file not shown.

View File

@ -17,6 +17,7 @@ struct Machine {
SMAIN: Vec<u16>,
SCODE: Vec<u16>,
IP: u16,
input: Vec<u8>,
}
impl Machine {
@ -272,6 +273,7 @@ impl Default for Machine {
RX: 0,
RY: 0,
RZ: 0,
input: vec![],
}
}
}
@ -517,6 +519,8 @@ impl Machine {
let a = self.read(ci.args[0]);
let b = self.read(ci.args[1]);
eprintln!("CMP({}, {})", a, b);
self.RSTAT.set(Flags::FZERO, a == 0 || b == 0);
self.RSTAT.set(Flags::FEQUL, a == b);
self.RSTAT.set(Flags::FLT, a < b);
@ -546,11 +550,7 @@ impl Machine {
self.RSTAT.set(Flags::FZERO, val == 0);
}
OP::READ => {
let mut input = 0;
std::io::stdin().read(&mut [input]).unwrap();
if input == b'~' { input = 0; }
let input = self.input.remove(0);
self.write(ci.args[0], input as u16);
self.RSTAT.set(Flags::FZERO, input == 0);
}
@ -658,6 +658,7 @@ fn main() {
let mut m = Machine::default();
m.SIN[1..=sin.inner().len()].copy_from_slice(sin.inner());
m.SCODE[1..=code.inner().len()].copy_from_slice(code.inner());
m.input = b"\x0a".to_vec();
// dump_instructions(&m.SCODE[1..=code.inner().len()]);