ft(interpreter): set flags for arithmatic operations
This commit is contained in:
@@ -27,8 +27,8 @@ pub enum ImmediateOperand {
|
||||
}
|
||||
|
||||
impl ImmediateOperand {
|
||||
// Sign-extend [`Self::Byte`] into [`Self::Word`].
|
||||
// Returns [`Self::Word`], if already a word.
|
||||
/// Sign-extend [`Self::Byte`] into [`Self::Word`].
|
||||
/// Returns [`Self::Word`], if already a word.
|
||||
pub fn sign_extend(self) -> Self {
|
||||
match self {
|
||||
Self::Byte(_) => {
|
||||
@@ -42,8 +42,8 @@ impl ImmediateOperand {
|
||||
}
|
||||
}
|
||||
|
||||
// Interprets [`Self::Byte`] as [`Self::Word`].
|
||||
// Returns word, if already a [`Self::Word`].
|
||||
/// Interprets [`Self::Byte`] as [`Self::Word`].
|
||||
/// Returns word, if already a [`Self::Word`].
|
||||
pub fn as_word(self) -> Self {
|
||||
match self {
|
||||
Self::Byte(b) => Self::Word(b as Word),
|
||||
@@ -51,7 +51,7 @@ impl ImmediateOperand {
|
||||
}
|
||||
}
|
||||
|
||||
// Flip most significant bit.
|
||||
/// Flip most significant bit.
|
||||
pub fn flip_sign(self) -> Self {
|
||||
match self {
|
||||
Self::Byte(b) => Self::Byte(b ^ (1 << 7)),
|
||||
@@ -59,7 +59,7 @@ impl ImmediateOperand {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if value is zero.
|
||||
/// Check if inner value is zero.
|
||||
pub fn zero(&self) -> bool {
|
||||
match self {
|
||||
Self::Byte(byte) => return *byte == 0,
|
||||
@@ -67,7 +67,7 @@ impl ImmediateOperand {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if leasy significant byte has even number of 1's.
|
||||
/// Check if leasy significant byte has even number of 1's.
|
||||
pub fn parity(&self) -> bool {
|
||||
match self {
|
||||
Self::Byte(byte) => return byte.count_ones() % 2 != 0,
|
||||
|
||||
Reference in New Issue
Block a user