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