gameboy superoptimizer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

23 lines
534 B

from dataclasses import dataclass
from typing import List, Optional, Union
from gbso.cpu.cpu import CPU
from gbso.cpu.regs import R8
from gbso.cpu.state import CPUState
from gbso.cpu.insn import Insn
# TODO: Support 16-bit memory/register outputs
Output = Union[R8, int]
@dataclass
class Program:
insns: List[Insn]
outputs: List[Output]
def execute(self, init_state: Optional[CPUState] = None) -> CPU:
cpu = CPU(state=init_state)
for insn in self.insns:
insn.exec(cpu)
return cpu