chore(interpreter): correctly sign extend for CBW/CWD intructions
This commit is contained in:
@@ -576,15 +576,19 @@ impl Interpreter {
|
||||
* Sign extensions
|
||||
*/
|
||||
Mnemonic::CBW => {
|
||||
// extend sign bit into AX, i.e. all bits set
|
||||
if ImmediateOperand::Byte(self.computer.regs.ax.lower).msb() {
|
||||
// extend sign bit into AX, i.e. all bits set
|
||||
self.computer.regs.ax.upper = 0xff;
|
||||
} else {
|
||||
self.computer.regs.ax.upper = 0x00;
|
||||
}
|
||||
}
|
||||
Mnemonic::CWD => {
|
||||
// extend sign bit into DX, i.e. all bits set
|
||||
if ImmediateOperand::Word(self.computer.regs.ax.read()).msb() {
|
||||
// extend sign bit into DX, i.e. all bits set
|
||||
self.computer.regs.dx.write(0xffff);
|
||||
} else {
|
||||
self.computer.regs.dx.write(0x0000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user