Setint opcode
This commit is contained in:
+5
-4
@@ -225,8 +225,10 @@ impl CPU {
|
|||||||
let x = self.pop_data();
|
let x = self.pop_data();
|
||||||
self.push_data(self.memory.peek24(x))
|
self.push_data(self.memory.peek24(x))
|
||||||
}
|
}
|
||||||
Opcode::Inton => self.int_enabled = true,
|
Opcode::Setint => {
|
||||||
Opcode::Intoff => self.int_enabled = false,
|
let x = self.pop_data();
|
||||||
|
self.int_enabled = x != 0;
|
||||||
|
}
|
||||||
Opcode::Setiv => self.iv = self.pop_data(),
|
Opcode::Setiv => self.iv = self.pop_data(),
|
||||||
Opcode::Sdp => {
|
Opcode::Sdp => {
|
||||||
self.push_data(self.sp);
|
self.push_data(self.sp);
|
||||||
@@ -322,8 +324,7 @@ impl Opcode {
|
|||||||
&& self != Hlt
|
&& self != Hlt
|
||||||
&& self != Load
|
&& self != Load
|
||||||
&& self != Loadw
|
&& self != Loadw
|
||||||
&& self != Inton
|
&& self != Setint
|
||||||
&& self != Intoff
|
|
||||||
&& self != Setiv
|
&& self != Setiv
|
||||||
&& self != Sdp
|
&& self != Sdp
|
||||||
&& self != Pushr
|
&& self != Pushr
|
||||||
|
|||||||
+20
-27
@@ -37,8 +37,7 @@ pub enum Opcode {
|
|||||||
Loadw,
|
Loadw,
|
||||||
Store,
|
Store,
|
||||||
Storew,
|
Storew,
|
||||||
Inton,
|
Setint,
|
||||||
Intoff,
|
|
||||||
Setiv,
|
Setiv,
|
||||||
Sdp,
|
Sdp,
|
||||||
Setsdp,
|
Setsdp,
|
||||||
@@ -167,11 +166,8 @@ impl Display for Opcode {
|
|||||||
Opcode::Storew => {
|
Opcode::Storew => {
|
||||||
write!(f, "storew")
|
write!(f, "storew")
|
||||||
}
|
}
|
||||||
Opcode::Inton => {
|
Opcode::Setint => {
|
||||||
write!(f, "inton")
|
write!(f, "setint")
|
||||||
}
|
|
||||||
Opcode::Intoff => {
|
|
||||||
write!(f, "intoff")
|
|
||||||
}
|
}
|
||||||
Opcode::Setiv => {
|
Opcode::Setiv => {
|
||||||
write!(f, "setiv")
|
write!(f, "setiv")
|
||||||
@@ -238,15 +234,14 @@ impl TryFrom<u8> for Opcode {
|
|||||||
31 => Loadw,
|
31 => Loadw,
|
||||||
32 => Store,
|
32 => Store,
|
||||||
33 => Storew,
|
33 => Storew,
|
||||||
34 => Inton,
|
34 => Setint,
|
||||||
35 => Intoff,
|
35 => Setiv,
|
||||||
36 => Setiv,
|
36 => Sdp,
|
||||||
37 => Sdp,
|
37 => Setsdp,
|
||||||
38 => Setsdp,
|
38 => Pushr,
|
||||||
39 => Pushr,
|
39 => Popr,
|
||||||
40 => Popr,
|
40 => Peekr,
|
||||||
41 => Peekr,
|
41 => Debug,
|
||||||
42 => Debug,
|
|
||||||
other => return Err(InvalidOpcode(other)),
|
other => return Err(InvalidOpcode(other)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -292,8 +287,7 @@ impl<'a> TryFrom<&'a str> for Opcode {
|
|||||||
"loadw" => Loadw,
|
"loadw" => Loadw,
|
||||||
"store" => Store,
|
"store" => Store,
|
||||||
"storew" => Storew,
|
"storew" => Storew,
|
||||||
"inton" => Inton,
|
"setint" => Setint,
|
||||||
"intoff" => Intoff,
|
|
||||||
"setiv" => Setiv,
|
"setiv" => Setiv,
|
||||||
"sdp" => Sdp,
|
"sdp" => Sdp,
|
||||||
"setsdp" => Setsdp,
|
"setsdp" => Setsdp,
|
||||||
@@ -343,15 +337,14 @@ impl From<Opcode> for u8 {
|
|||||||
Opcode::Loadw => 31,
|
Opcode::Loadw => 31,
|
||||||
Opcode::Store => 32,
|
Opcode::Store => 32,
|
||||||
Opcode::Storew => 33,
|
Opcode::Storew => 33,
|
||||||
Opcode::Inton => 34,
|
Opcode::Setint => 34,
|
||||||
Opcode::Intoff => 35,
|
Opcode::Setiv => 35,
|
||||||
Opcode::Setiv => 36,
|
Opcode::Sdp => 36,
|
||||||
Opcode::Sdp => 37,
|
Opcode::Setsdp => 37,
|
||||||
Opcode::Setsdp => 38,
|
Opcode::Pushr => 38,
|
||||||
Opcode::Pushr => 39,
|
Opcode::Popr => 39,
|
||||||
Opcode::Popr => 40,
|
Opcode::Peekr => 40,
|
||||||
Opcode::Peekr => 41,
|
Opcode::Debug => 41,
|
||||||
Opcode::Debug => 42,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user