diff --git a/Epreuve3.py b/Epreuve3.py index 28a81e0..deb2b07 100644 --- a/Epreuve3.py +++ b/Epreuve3.py @@ -24,6 +24,7 @@ class CPU: cycles: int = 0 running: bool = True after_ret: bool = False + last_out = None def __post_init__(self): if not self.regs: @@ -189,6 +190,7 @@ class Simulator: r = b & 0b11 instr = f"OUT R{r}" print(f"[OUT] R{r} = {c.regs[r]}") + self.cpu.last_out = c.regs[r] # --- TIM valeur --- elif b == 0xF8: # TIM @@ -228,16 +230,19 @@ class Simulator: print(f" {regs_str} LT={c.lt} EQ={c.eq} SP={c.sp}") print("-" * 60) ram = self.dump_ram() + out = self.cpu.last_out + self.cpu.last_out = None return { - "pc": pc_before, - "instr": instr, - "cycles_added": cycles_added, - "regs": c.regs.copy(), - "lt": c.lt, - "eq": c.eq, - "sp": c.sp, - "ram": ram - } + "pc": pc_before, + "instr": instr, + "cycles_added": cycles_added, + "regs": c.regs.copy(), + "lt": c.lt, + "eq": c.eq, + "sp": c.sp, + "ram": ram, + "out": out + } # ----------------- boucle principale ----------------- diff --git a/Path.asm b/Path.asm index 1f3be12..82633ae 100644 --- a/Path.asm +++ b/Path.asm @@ -12,26 +12,57 @@ _main: MOV R0 51 OUT R0 - TIM 165 ; Ligne droite OK + TIM 164 ; Ligne droite OK MOV R0 49 ; 0b 0011 0001 OUT R0 - TIM 130 ; Rotation droite OK + TIM 131 ; Rotation droite OK MOV R0 51 OUT R0 - TIM 152 ; Ligne droite + TIM 147 ; Ligne droite MOV R0 19 ; 0b 0001 0011 OUT R0 - TIM 130 ; Rotation gauche + TIM 131 ; Rotation gauche ;TIM 50 MOV R0 51 OUT R0 - TIM 136 ; Ligne droite + TIM 138 ; Ligne droite + + MOV R0 0 + OUT R0 ; STOP + TIM 160 + + MOV R0 162 + OUT R0 + TIM 135 ; Rotation gauche + + MOV R0 0 + OUT R0 ; STOP + TIM 140 + + MOV R0 42 + OUT R0 + TIM 135 ; Rotation droite + + MOV R0 0 + OUT R0 ; STOP + TIM 160 + + MOV R0 247 + OUT R0 + TIM 130 ; Rotation gauche + + MOV R0 127 + OUT R0 + TIM 130 ; Rotation droite + + MOV R0 247 + OUT R0 + TIM 180 ; Rotation gauche - MOV R0 0 OUT R0 ; STOP diff --git a/__pycache__/assembleur.cpython-314.pyc b/__pycache__/assembleur.cpython-314.pyc deleted file mode 100644 index ba38b91..0000000 Binary files a/__pycache__/assembleur.cpython-314.pyc and /dev/null differ diff --git a/notes.txt b/notes.txt index e222239..bcc4863 100644 --- a/notes.txt +++ b/notes.txt @@ -177,6 +177,8 @@ Demi tour + fuite Parcours {"type": "msg", "format": "base64", "string": "4BHw+ILgIvD4guAz8Pil4DHw+ILgM/D4mOAT8PiC4DPw+IjgAPCA4ADw+GSA"} +{"type": "msg", "format": "base64", "string": "4BHw+ILgIvD4guAz8Pik4DHw+IPgM/D4k+AT8PiD4DPw+IrgAPD4oOCi8PiH4ADw+IzgKvD4h+AA8Pig4Pfw+ILgf/D4guD38Pi04ADwgOAA8PhkgA=="} + diff --git a/out.bin b/out.bin index 9f6357d..779db75 100644 Binary files a/out.bin and b/out.bin differ diff --git a/simulateur_front.py b/simulateur_front.py index d245a37..2d15818 100644 --- a/simulateur_front.py +++ b/simulateur_front.py @@ -54,6 +54,16 @@ Label(single_inst_frame, text=f"Instruction").pack(pady=5, side=LEFT) single_instr = Label(single_inst_frame, text=f"instruction+cycle", width=30, bg="white") single_instr.pack(pady=5, side=tk.LEFT) +# Boutons +buttons_frame = tk.Frame(instructions_frame, width=400, height=100, bg="#89B4E1") +buttons_frame.pack(padx=5, pady=5, side=tk.TOP) + +buttonAll = tk.Button(root, text="All In") +buttonStep = tk.Button(root, text="Step By Step") + +buttonAll.pack(in_=buttons_frame, side=tk.LEFT) +buttonStep.pack(in_=buttons_frame, side=tk.LEFT) + image_frame = tk.Frame(instructions_frame, width=400, height=100, bg="#89B4E1") image_frame.pack(padx=5, pady=5, side=tk.TOP) @@ -195,7 +205,7 @@ scrollbarOut.config(command=myOutList.yview) previous_sp = None # Initialisation avant la première itération def update_gui(): - global previous_sp # Accéder à la variable globale previous_sp + global previous_sp, sim_iter # Accéder à la variable globale previous_sp try: state = next(sim_iter) @@ -234,6 +244,9 @@ def update_gui(): hex_values = " ".join(f"{b:02X}" for b in chunk) myRamList.insert(tk.END, f"{addr:02X}: {hex_values}") + if (state["out"] != None): + myOutList.insert(tk.END, state["out"]) + # relance automatique root.after(200, update_gui)