def lda_imm(comp: Computer): comp.pc += 1 data = comp.getat(comp.pc) comp.accum = data
def lda2(comp: Computer): ptr = getat_pages(comp, True) data = comp.getat(ptr) comp.accum = data
def ldy_imm(comp: Computer): comp.pc += 1 data = comp.getat(comp.pc) comp.regy = data
def ldy2(comp: Computer): ptr = getat_pages(comp, True) data = comp.getat(ptr) comp.regy = data
def ldx(comp: Computer): ptr = getat_pages(comp) data = comp.getat(ptr) comp.regx = data
def getat_pages(comp: Computer, pageswitch: bool = False): if pageswitch: comp.pc += 2 return comp.getat(comp.pc - 1) * 256 + comp.getat(comp.pc) comp.pc += 1 return comp.getat(comp.pc)
def sub2(comp: Computer): ptr = getat_pages(comp, True) data = comp.getat(ptr) comp.accum -= data comp.overflow = comp.accum < 0 comp.accum %= 256
def sbi(comp: Computer): comp.pc += 1 data = comp.getat(comp.pc) comp.accum -= data comp.overflow = comp.accum < 0 comp.accum %= 256
def add2(comp: Computer): ptr = getat_pages(comp, True) data = comp.getat(ptr) comp.accum += data comp.overflow = comp.accum > 255 comp.accum %= 256
def adi(comp: Computer): comp.pc += 1 data = comp.getat(comp.pc) comp.accum += data comp.overflow = comp.accum > 255 comp.accum %= 256
def sti2(comp: Computer): ptr = getat_pages(comp, True) comp.pc += 1 data = comp.getat(comp.pc) comp.setat(ptr, data)