ft(interpreter): impl all low-hanging fruit instructions

This commit is contained in:
2025-06-11 23:29:34 +09:00
parent 4cea76bd1c
commit 5942270f63
4 changed files with 105 additions and 4 deletions

View File

@@ -110,6 +110,20 @@ impl Computer {
self.op(op, flag_set, false, dest, src);
}
/// Perform test operation, which acts like [`Self::and()`], but without
/// saving the result and only setting [`Self::flags`].
pub fn test(&mut self, dest: ModRmTarget, src: Operand) {
let op: fn(Lhs, Rhs) -> ArithmeticResult = |lhs, rhs| lhs & rhs;
let flag_set: fn(&mut Flags, ArithmeticResult, Lhs, Rhs) = |flags, result, _, _| {
flags.cf = false;
flags.of = false;
flags.zf = result.zero();
flags.sf = result.msb();
flags.pf = result.parity();
};
self.op(op, flag_set, false, dest, src);
}
/// Perform `dest` = `dest` + `src` + CF. Sets flags.
pub fn adc(&mut self, dest: ModRmTarget, src: Operand) {
let cf = self.flags.cf as u8;