66instruction handlers by defining methods named ``op_<mnemonic>`` on ``CPU``.
77"""
88
9- from typing import Dict , List , Optional , Tuple
9+ from typing import Optional
1010
1111from .memory import Memory
1212
@@ -29,18 +29,18 @@ class CPU:
2929 currently-loaded program.
3030
3131 Attributes:
32- regs (List [int]): 32 8-bit general purpose registers (R0..R31).
32+ regs (list [int]): 32 8-bit general purpose registers (R0..R31).
3333 pc (int): Program counter (index into ``program``).
3434 sp (int): Stack pointer (index into RAM in the associated
3535 :class:`tiny8.memory.Memory`).
3636 sreg (int): Status register bits stored in a single integer (I, T,
3737 H, S, V, N, Z, C).
3838 cycle (int): Instruction execution counter.
39- reg_trace (List[Tuple [int, int, int]]): Per-cycle register change
39+ reg_trace (list[tuple [int, int, int]]): Per-cycle register change
4040 trace entries of the form ``(cycle, reg, new_value)``.
41- mem_trace (List[Tuple [int, int, int]]): Per-cycle memory change
41+ mem_trace (list[tuple [int, int, int]]): Per-cycle memory change
4242 trace entries of the form ``(cycle, addr, new_value)``.
43- step_trace (List [dict]): Full per-step snapshots useful for
43+ step_trace (list [dict]): Full per-step snapshots useful for
4444 visualization and debugging.
4545
4646 Note:
@@ -52,7 +52,7 @@ class CPU:
5252 def __init__ (self , memory : Optional [Memory ] = None ):
5353 self .mem = memory or Memory ()
5454 # 32 general purpose 8-bit registers R0-R31
55- self .regs : List [int ] = [0 ] * 32
55+ self .regs : [int ] = [0 ] * 32
5656 # Program Counter (word-addressable for AVR) - we use byte addressing for simplicity
5757 self .pc : int = 0
5858 # Stack Pointer - point into RAM
@@ -62,16 +62,16 @@ def __init__(self, memory: Optional[Memory] = None):
6262 # Cycle counter
6363 self .cycle : int = 0
6464 # Simple interrupt vector table (addr->enabled)
65- self .interrupts : Dict [int , bool ] = {}
65+ self .interrupts : dict [int , bool ] = {}
6666 # Execution trace of register/memory changes per cycle
67- self .reg_trace : List [ Tuple [int , int , int ]] = [] # (cycle, reg, newval)
68- self .mem_trace : List [ Tuple [int , int , int ]] = [] # (cycle, addr, newval)
67+ self .reg_trace : list [ tuple [int , int , int ]] = [] # (cycle, reg, newval)
68+ self .mem_trace : list [ tuple [int , int , int ]] = [] # (cycle, addr, newval)
6969 # Full step trace: list of dicts with cycle, pc, instr_text, regs snapshot, optional mem snapshot
70- self .step_trace : List [dict ] = []
70+ self .step_trace : list [dict ] = []
7171 # Program area - list of instructions as tuples: (mnemonic, *operands)
72- self .program : List [ Tuple [str , Tuple ]] = []
72+ self .program : list [ tuple [str , tuple ]] = []
7373 # Labels -> pc
74- self .labels : Dict [str , int ] = {}
74+ self .labels : dict [str , int ] = {}
7575 # Running state
7676 self .running = False
7777
@@ -289,11 +289,11 @@ def write_ram(self, addr: int, val: int) -> None:
289289 self .mem_trace .append ((self .cycle , addr , val & 0xFF ))
290290
291291 # Program loading
292- def load_program (self , program : List [ Tuple [str , Tuple ]], labels : Dict [str , int ]):
292+ def load_program (self , program : list [ tuple [str , tuple ]], labels : dict [str , int ]):
293293 """Load an assembled program into the CPU.
294294
295295 Args:
296- program: List of ``(mnemonic, operands)`` tuples returned by the
296+ program: list of ``(mnemonic, operands)`` tuples returned by the
297297 assembler.
298298 labels: Mapping of label strings to instruction indices.
299299
0 commit comments