MCPcopy Create free account
hub / github.com/fogleman/nes / sbc

Method sbc

nes/cpu.go:835–851  ·  view source on GitHub ↗

SBC - Subtract with Carry

(info *stepInfo)

Source from the content-addressed store, hash-verified

833
834// SBC - Subtract with Carry
835func (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
854func (cpu *CPU) sec(info *stepInfo) {

Callers

nothing calls this directly

Calls 2

setZNMethod · 0.95
ReadMethod · 0.65

Tested by

no test coverage detected