rustfmt
This commit is contained in:
parent
eee9bd4ec2
commit
e16e71b04a
26
src/main.rs
26
src/main.rs
|
@ -1,6 +1,6 @@
|
|||
use byteorder::{ReadBytesExt, LE};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::io::Cursor;
|
||||
use std::convert::{TryInto, TryFrom};
|
||||
use std::io::Read;
|
||||
|
||||
struct Machine {
|
||||
|
@ -40,9 +40,9 @@ impl Machine {
|
|||
Register::RY => self.RY = val,
|
||||
Register::RZ => self.RZ = val,
|
||||
Register::RTRGT => self.RTRGT = val,
|
||||
Register::RSTAT => {}, // writes have no effect
|
||||
Register::RCALL => {},
|
||||
Register::NULL => {},
|
||||
Register::RSTAT => {} // writes have no effect
|
||||
Register::RCALL => {}
|
||||
Register::NULL => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl Machine {
|
|||
fn write(&mut self, a: Arg, val: u16) {
|
||||
match a {
|
||||
Arg::Register(r) => self.write_reg(r, val),
|
||||
Arg::SIN(v) => {},
|
||||
Arg::SIN(v) => {}
|
||||
Arg::SMAIN(v) => self.SMAIN[v as usize] = val,
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,6 @@ impl Register {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bitflags::bitflags! {
|
||||
struct Flags: u16 {
|
||||
const FZERO = 0b0000000000000001;
|
||||
|
@ -167,8 +166,6 @@ RCPF = 0x043 ,
|
|||
impl std::convert::Into<OP> for u16 {
|
||||
fn into(self) -> OP {
|
||||
match self {
|
||||
|
||||
|
||||
0x000 => OP::HALT,
|
||||
0x001 => OP::NOOP,
|
||||
0x002 => OP::INC,
|
||||
|
@ -413,9 +410,7 @@ fn parse_instruction(mut bytes: &[u16]) -> (Instruction, usize) {
|
|||
};
|
||||
|
||||
match aflg {
|
||||
AFLG::Register => {
|
||||
args.push(Arg::Register(registers.remove(0)))
|
||||
},
|
||||
AFLG::Register => args.push(Arg::Register(registers.remove(0))),
|
||||
AFLG::SIN => {
|
||||
args.push(Arg::SIN(bytes[0]));
|
||||
bytes = &bytes[1..];
|
||||
|
@ -429,8 +424,6 @@ fn parse_instruction(mut bytes: &[u16]) -> (Instruction, usize) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
(Instruction { def, args }, consumed)
|
||||
}
|
||||
|
||||
|
@ -471,7 +464,7 @@ impl Machine {
|
|||
|
||||
match oc {
|
||||
OP::HALT => return false,
|
||||
OP::NOOP => {},
|
||||
OP::NOOP => {}
|
||||
OP::XOR => {
|
||||
let arg0 = self.read(ci.args[0]);
|
||||
let arg1 = self.read(ci.args[1]);
|
||||
|
@ -649,7 +642,10 @@ impl Machine {
|
|||
self.write(ci.args[0], val);
|
||||
self.RSTAT.set(Flags::FZERO, val == 0);
|
||||
}
|
||||
_ => { eprintln!("unsupported opcode {:?}", oc); return false; }
|
||||
_ => {
|
||||
eprintln!("unsupported opcode {:?}", oc);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if should_inc_ip {
|
||||
|
|
Loading…
Reference in New Issue