From 46f11eee5784db254b037f4e24472abe9820ca70 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Sat, 23 Apr 2022 13:35:54 -0500 Subject: [PATCH] Setint opcode --- vcore/src/cpu.rs | 9 +++++---- vcore/src/opcodes.rs | 47 +++++++++++++++++++------------------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/vcore/src/cpu.rs b/vcore/src/cpu.rs index f39a202..b271acd 100644 --- a/vcore/src/cpu.rs +++ b/vcore/src/cpu.rs @@ -225,8 +225,10 @@ impl CPU { let x = self.pop_data(); self.push_data(self.memory.peek24(x)) } - Opcode::Inton => self.int_enabled = true, - Opcode::Intoff => self.int_enabled = false, + Opcode::Setint => { + let x = self.pop_data(); + self.int_enabled = x != 0; + } Opcode::Setiv => self.iv = self.pop_data(), Opcode::Sdp => { self.push_data(self.sp); @@ -322,8 +324,7 @@ impl Opcode { && self != Hlt && self != Load && self != Loadw - && self != Inton - && self != Intoff + && self != Setint && self != Setiv && self != Sdp && self != Pushr diff --git a/vcore/src/opcodes.rs b/vcore/src/opcodes.rs index ac43bd0..c2cef20 100644 --- a/vcore/src/opcodes.rs +++ b/vcore/src/opcodes.rs @@ -37,8 +37,7 @@ pub enum Opcode { Loadw, Store, Storew, - Inton, - Intoff, + Setint, Setiv, Sdp, Setsdp, @@ -167,11 +166,8 @@ impl Display for Opcode { Opcode::Storew => { write!(f, "storew") } - Opcode::Inton => { - write!(f, "inton") - } - Opcode::Intoff => { - write!(f, "intoff") + Opcode::Setint => { + write!(f, "setint") } Opcode::Setiv => { write!(f, "setiv") @@ -238,15 +234,14 @@ impl TryFrom for Opcode { 31 => Loadw, 32 => Store, 33 => Storew, - 34 => Inton, - 35 => Intoff, - 36 => Setiv, - 37 => Sdp, - 38 => Setsdp, - 39 => Pushr, - 40 => Popr, - 41 => Peekr, - 42 => Debug, + 34 => Setint, + 35 => Setiv, + 36 => Sdp, + 37 => Setsdp, + 38 => Pushr, + 39 => Popr, + 40 => Peekr, + 41 => Debug, other => return Err(InvalidOpcode(other)), }) } @@ -292,8 +287,7 @@ impl<'a> TryFrom<&'a str> for Opcode { "loadw" => Loadw, "store" => Store, "storew" => Storew, - "inton" => Inton, - "intoff" => Intoff, + "setint" => Setint, "setiv" => Setiv, "sdp" => Sdp, "setsdp" => Setsdp, @@ -343,15 +337,14 @@ impl From for u8 { Opcode::Loadw => 31, Opcode::Store => 32, Opcode::Storew => 33, - Opcode::Inton => 34, - Opcode::Intoff => 35, - Opcode::Setiv => 36, - Opcode::Sdp => 37, - Opcode::Setsdp => 38, - Opcode::Pushr => 39, - Opcode::Popr => 40, - Opcode::Peekr => 41, - Opcode::Debug => 42, + Opcode::Setint => 34, + Opcode::Setiv => 35, + Opcode::Sdp => 36, + Opcode::Setsdp => 37, + Opcode::Pushr => 38, + Opcode::Popr => 39, + Opcode::Peekr => 40, + Opcode::Debug => 41, } } }