SBC - Subtract with Carry
(info *stepInfo)
| 833 | |
| 834 | // SBC - Subtract with Carry |
| 835 | func (cpu *CPU) sbc(info *stepInfo) { |
| 836 | a := cpu.A |
| 837 | b := cpu.Read(info.address) |
| 838 | c := cpu.C |
| 839 | cpu.A = a - b - (1 - c) |
| 840 | cpu.setZN(cpu.A) |
| 841 | if int(a)-int(b)-int(1-c) >= 0 { |
| 842 | cpu.C = 1 |
| 843 | } else { |
| 844 | cpu.C = 0 |
| 845 | } |
| 846 | if (a^b)&0x80 != 0 && (a^cpu.A)&0x80 != 0 { |
| 847 | cpu.V = 1 |
| 848 | } else { |
| 849 | cpu.V = 0 |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | // SEC - Set Carry Flag |
| 854 | func (cpu *CPU) sec(info *stepInfo) { |