Add CMP to execute_instruction().

This commit is contained in:
Andrew Keeton 2014-11-13 20:15:40 -05:00
parent 8b962fd542
commit a05a5dfde7
1 changed files with 8 additions and 1 deletions

View File

@ -188,6 +188,14 @@ impl Machine {
self.registers.status.and(!PS_OVERFLOW);
}
(instruction::CMP, instruction::UseImmediate(val)) => {
self.compare(val);
}
(instruction::CMP, instruction::UseAddress(addr)) => {
let val = self.memory.get_byte(addr);
self.compare(val);
}
(instruction::DEC, instruction::UseAddress(addr)) => {
self.decrement_memory(addr)
}
@ -619,7 +627,6 @@ impl Machine {
}
}
// From http://www.6502.org/tutorials/compare_beyond.html:
// If the Z flag is 0, then A <> NUM and BNE will branch
// If the Z flag is 1, then A = NUM and BEQ will branch