add error print, allow entering null
This commit is contained in:
parent
f438280d6c
commit
ad17d8f8b2
|
@ -68,7 +68,7 @@ impl Machine {
|
|||
fn write(&mut self, a: Arg, val: u16) {
|
||||
match a {
|
||||
Arg::Register(r) => self.write_reg(r, val),
|
||||
Arg::SIN(v) => self.SIN[v as usize] = val,
|
||||
Arg::SIN(v) => {},
|
||||
Arg::SMAIN(v) => self.SMAIN[v as usize] = val,
|
||||
}
|
||||
}
|
||||
|
@ -458,6 +458,7 @@ impl Arg {
|
|||
impl Machine {
|
||||
fn step(&mut self) -> bool {
|
||||
let (ci, inc_by) = parse_instruction(&self.SCODE[(self.IP as usize)..]);
|
||||
eprintln!("{:?}", ci);
|
||||
//dbg!(&ci);
|
||||
|
||||
let oc = ci.def.opcode();
|
||||
|
@ -545,9 +546,11 @@ impl Machine {
|
|||
self.RSTAT.set(Flags::FZERO, val == 0);
|
||||
}
|
||||
OP::READ => {
|
||||
let input = 0;
|
||||
let mut input = 0;
|
||||
std::io::stdin().read(&mut [input]).unwrap();
|
||||
|
||||
if input == b'~' { input = 0; }
|
||||
|
||||
self.write(ci.args[0], input as u16);
|
||||
self.RSTAT.set(Flags::FZERO, input == 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue