func bne(cpu *CPU, addrMode addressingMode) {
	if !cpu.getFlag(StatusFlagZ) {
		cpu.regs.PC = calculateAddr(cpu, addrMode)
		cpu.jumped = true
	}
}
Branch if not equal
package awesomenes
import (
	"log"
)
type instr struct {
	name     string
	size     uint8
	cycles   uint8
	addrMode addressingMode
	fn       func(cpu *CPU, addrMode addressingMode)
}
type addressingMode uint8
const (
	AddrModeAbs addressingMode = iota
	AddrModeAbsX
	AddrModeAbsY
	AddrModeAccumulator
	AddrModeImmediate
	AddrModeImplied
	AddrModeIndirect
	AddrModeXIndirect
	AddrModeIndirectY
	AddrModeRelative
	AddrModeZeroPage
	AddrModeZeroX
	AddrModeZeroY
)
func calculateAddr(cpu *CPU, addrMode addressingMode) uint16 {
	switch addrMode {
	case AddrModeAbs:
		return cpu.mem.Read16(cpu.regs.PC + 1)
	case AddrModeAbsX:
		return cpu.mem.Read16(cpu.regs.PC+1) + uint16(cpu.regs.X)
	case AddrModeAbsY:
		return cpu.mem.Read16(cpu.regs.PC+1) + uint16(cpu.regs.Y)
	case AddrModeAccumulator:
		log.Fatalf("It makes no sense to calculate addresses in accumulator addressing mode")
		return 0xffff
	case AddrModeImmediate:
		return cpu.regs.PC + 1
	case AddrModeRelative:
		offset := uint16(cpu.mem.Read8(cpu.regs.PC + 1))
		if offset < 0x80 {
			return cpu.regs.PC + 2 + offset
		} else {
			return cpu.regs.PC + 2 + offset - 0x100
		}
	case AddrModeIndirect:
		m := cpu.mem.Read16(cpu.regs.PC + 1)
		return cpu.read16AndMaybeWrap(m)
	case AddrModeXIndirect:
		m := cpu.mem.Read8(cpu.regs.PC + 1)
		x := cpu.regs.X
		return cpu.read16AndMaybeWrap(uint16(m + x))
	case AddrModeIndirectY:
		m := cpu.mem.Read8(cpu.regs.PC + 1)
		y := cpu.regs.Y
		return cpu.read16AndMaybeWrap(uint16(m)) + uint16(y)
	case AddrModeZeroPage:
		return uint16(cpu.mem.Read8(cpu.regs.PC + 1))
	case AddrModeZeroX:
		return uint16(cpu.mem.Read8(cpu.regs.PC+1) + cpu.regs.X)
	default:
		log.Fatalf("Invalid addressing mode")
		return 0xffff
	}
}
func brk(cpu *CPU, addrMode addressingMode) {
	cpu.Push16(cpu.regs.PC)
	cpu.Push8(cpu.regs.P)
	cpu.setFlag(StatusFlagB)
	cpu.regs.PC = cpu.mem.Read16(0xfffe)
	cpu.jumped = true
}
func ora(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	cpu.regs.A = cpu.regs.A | cpu.mem.Read8(addr)
	cpu.setOrReset(StatusFlagN, cpu.regs.A&0x80 != 0)
	cpu.setOrReset(StatusFlagZ, cpu.regs.A == 0)
}
func eor(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	cpu.regs.A = cpu.regs.A ^ cpu.mem.Read8(addr)
	cpu.setOrReset(StatusFlagN, cpu.regs.A&0x80 != 0)
	cpu.setOrReset(StatusFlagZ, cpu.regs.A == 0)
}
func asl(cpu *CPU, addrMode addressingMode) {
	shiftL := func(v uint8) uint8 {
		cpu.setOrReset(StatusFlagC, v&0x80 != 0)
		v = v << 1
		setOrResetNZ(v, cpu)
		return v
	}
	if addrMode == AddrModeAccumulator {
		cpu.regs.A = shiftL(cpu.regs.A)
	} else {
		addr := calculateAddr(cpu, addrMode)
		cpu.mem.Write8(addr, shiftL(cpu.mem.Read8(addr)))
	}
}
func lsr(cpu *CPU, addrMode addressingMode) {
	shiftR := func(v uint8) uint8 {
		cpu.setOrReset(StatusFlagC, v&0x1 == 0x1)
		v = v >> 1
		setOrResetNZ(v, cpu)
		return v
	}
	if addrMode == AddrModeAccumulator {
		cpu.regs.A = shiftR(cpu.regs.A)
	} else {
		addr := calculateAddr(cpu, addrMode)
		cpu.mem.Write8(addr, shiftR(cpu.mem.Read8(addr)))
	}
}
func adc(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	a := cpu.regs.A
	b := cpu.mem.Read8(addr)
	var c uint8 = 0
	if cpu.getFlag(StatusFlagC) {
		c = 1
	}
	cpu.regs.A = a + b + c
	setOrResetNZ(cpu.regs.A, cpu)
	cpu.setOrReset(StatusFlagC, int(a)+int(b)+int(c) > 0xFF)
	cpu.setOrReset(StatusFlagV, (a^b)&0x80 == 0 && (a^cpu.regs.A)&0x80 != 0)
}
func sbc(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	a := cpu.regs.A
	b := cpu.mem.Read8(addr)
	var c uint8 = 0
	if cpu.getFlag(StatusFlagC) {
		c = 1
	}
	cpu.regs.A = a - b - (1 - c)
	setOrResetNZ(cpu.regs.A, cpu)
	cpu.setOrReset(StatusFlagC, int(a)-int(b)-int(1-c) >= 0x00)
	cpu.setOrReset(StatusFlagV, (a^b)&0x80 != 0 && (a^cpu.regs.A)&0x80 != 0)
}
func php(cpu *CPU, addrMode addressingMode) {
	cpu.Push8(cpu.regs.P | 0x10)
}
func pha(cpu *CPU, addrMode addressingMode) {
	cpu.Push8(cpu.regs.A)
}
func plp(cpu *CPU, addrMode addressingMode) {
	cpu.regs.P = cpu.Pop8()&0xEF | 0x20
}
func pla(cpu *CPU, addrMode addressingMode) {
	cpu.regs.A = cpu.Pop8()
	setOrResetNZ(cpu.regs.A, cpu)
}
func clc(cpu *CPU, addrMode addressingMode) {
	cpu.resetFlag(StatusFlagC)
}
func cld(cpu *CPU, addrMode addressingMode) {
	cpu.resetFlag(StatusFlagD)
}
func cli(cpu *CPU, addrMode addressingMode) {
	cpu.resetFlag(StatusFlagI)
}
func clv(cpu *CPU, addrMode addressingMode) {
	cpu.resetFlag(StatusFlagV)
}
func jmp(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	cpu.regs.PC = addr
	cpu.jumped = true
}
func jsr(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	cpu.Push16(cpu.regs.PC - 1 + 3)
	cpu.regs.PC = addr
	cpu.jumped = true
}
func rti(cpu *CPU, addrMode addressingMode) {
	cpu.regs.P = cpu.Pop8()&0xEF | 0x20
	cpu.regs.PC = cpu.Pop16()
	cpu.jumped = true
}
func rts(cpu *CPU, addrMode addressingMode) {
	cpu.regs.PC = cpu.Pop16() + 1
	cpu.jumped = true
}
func and(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	cpu.regs.A = cpu.regs.A & cpu.mem.Read8(addr)
	cpu.setOrReset(StatusFlagN, cpu.regs.A&0x80 != 0)
	cpu.setOrReset(StatusFlagZ, cpu.regs.A == 0)
}
func bit(cpu *CPU, addrMode addressingMode) {
	addr := calculateAddr(cpu, addrMode)
	v := cpu.mem.Read8(addr)
	cpu.setOrReset(StatusFlagZ, cpu.regs.A&v == 0)
	cpu.setOrReset(StatusFlagN, (v>>7)&0x1 == 0x1)
	cpu.setOrReset(StatusFlagV, (v>>6)&0x1 == 0x1)
}
func rol(cpu *CPU, addrMode addressingMode) {
	inner := func(v uint8) uint8 {
		var c uint8 = 0
		if cpu.getFlag(StatusFlagC) {
			c = 1
		}
		cpu.setOrReset(StatusFlagC, (v>>7)&0x1 == 0x1)
		v = (v << 1) | c
		setOrResetNZ(v, cpu)
		return v
	}
	if addrMode == AddrModeAccumulator {
		cpu.regs.A = inner(cpu.regs.A)
	} else {
		addr := calculateAddr(cpu, addrMode)
		cpu.mem.Write8(addr, inner(cpu.mem.Read8(addr)))
	}
}
func ror(cpu *CPU, addrMode addressingMode) {
	inner := func(v uint8) uint8 {
		var c uint8 = 0
		if cpu.getFlag(StatusFlagC) {
			c = 1
		}
		cpu.setOrReset(StatusFlagC, v&0x1 == 0x1)
		v = (v >> 1) | (c << 7)
		setOrResetNZ(v, cpu)
		return v
	}
	if addrMode == AddrModeAccumulator {
		cpu.regs.A = inner(cpu.regs.A)
	} else {
		addr := calculateAddr(cpu, addrMode)
		cpu.mem.Write8(addr, inner(cpu.mem.Read8(addr)))
	}
}
func bcc(cpu *CPU, addrMode addressingMode) {
	if !cpu.getFlag(StatusFlagC) {
		cpu.regs.PC = calculateAddr(cpu, addrMode)
		cpu.jumped = true
	}
}
func bcs(cpu *CPU, addrMode addressingMode) {
	if cpu.getFlag(StatusFlagC) {
		cpu.regs.PC = calculateAddr(cpu, addrMode)
		cpu.jumped = true
	}
}
func bmi(cpu *CPU, addrMode addressingMode) {
	if cpu.getFlag(StatusFlagN) {
		cpu.regs.PC = calculateAddr(cpu, addrMode)
		cpu.jumped = true
	}
}
func beq(cpu *CPU, addrMode addressingMode) {
	if cpu.getFlag(StatusFlagZ) {
		cpu.regs.PC = calculateAddr(cpu, addrMode)
		cpu.jumped = true
	}
}