Ajout du OUT

This commit is contained in:
Nogard 2026-03-22 09:36:59 +01:00
parent 20ed1e558e
commit f76307ecc1
6 changed files with 67 additions and 16 deletions

View File

@ -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 -----------------

View File

@ -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

View File

@ -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=="}

BIN
out.bin

Binary file not shown.

View File

@ -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)