ft(interpreter): impl push/pop
This commit is contained in:
@@ -34,9 +34,9 @@ impl ImmediateOperand {
|
||||
match self {
|
||||
Self::Byte(_) => {
|
||||
return if self.msb() {
|
||||
self.flip_sign().as_word().flip_sign()
|
||||
self.flip_sign().word().flip_sign()
|
||||
} else {
|
||||
self.as_word()
|
||||
self.word()
|
||||
};
|
||||
}
|
||||
Self::Word(_) => self,
|
||||
@@ -46,7 +46,7 @@ impl ImmediateOperand {
|
||||
/// Interprets [`Self::Byte`] as [`Self::Word`].
|
||||
/// Returns word, if already a [`Self::Word`].
|
||||
/// CAUTION: You probably want to use [`Self::sign_extend()`] instead.
|
||||
fn as_word(self) -> Self {
|
||||
fn word(self) -> Self {
|
||||
match self {
|
||||
Self::Byte(b) => Self::Word(b as Word),
|
||||
Self::Word(_) => self,
|
||||
@@ -566,7 +566,7 @@ mod tests {
|
||||
let b: u8 = 5;
|
||||
let byte = ImmediateOperand::Byte(b);
|
||||
let word = ImmediateOperand::Word(b as Word);
|
||||
assert_eq!(byte.as_word(), word);
|
||||
assert_eq!(byte.word(), word);
|
||||
assert_eq!(word, word);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user