CLI changes
This commit is contained in:
+5
-1
@@ -60,11 +60,15 @@ def run_classic_cli():
|
|||||||
print("Done.")
|
print("Done.")
|
||||||
|
|
||||||
def run_exhaustive_cli():
|
def run_exhaustive_cli():
|
||||||
|
print("\nR registers are indexed 0–7; bits within each register are 0–7.")
|
||||||
|
print("Enter -1 to print all bits in the chosen register.")
|
||||||
|
|
||||||
steps = prompt_int("How many steps? (1–100): ", 1, 100)
|
steps = prompt_int("How many steps? (1–100): ", 1, 100)
|
||||||
target_reg = prompt_int("Target register (0–7): ", 0, 7)
|
target_reg = prompt_int("Target register (0–7): ", 0, 7)
|
||||||
|
target_bit = prompt_int("Target bit (-1 or 0–7): ", -1, 7)
|
||||||
|
|
||||||
print("-" * 50)
|
print("-" * 50)
|
||||||
run_exhaustive(steps, target_reg)
|
run_exhaustive(steps, target_reg, target_bit)
|
||||||
|
|
||||||
print("\n" + "=" * 50)
|
print("\n" + "=" * 50)
|
||||||
print("Done.")
|
print("Done.")
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def apply_variable_change(model, coeffs):
|
|||||||
new_R.append(row)
|
new_R.append(row)
|
||||||
return new_R
|
return new_R
|
||||||
|
|
||||||
def run_exhaustive(steps: int, target_reg: int = 0):
|
def run_exhaustive(steps: int, target_reg: int = 0, target_bit: int = -1):
|
||||||
model = Tea3Model()
|
model = Tea3Model()
|
||||||
for _ in range(steps):
|
for _ in range(steps):
|
||||||
model.step()
|
model.step()
|
||||||
@@ -37,6 +37,14 @@ def run_exhaustive(steps: int, target_reg: int = 0):
|
|||||||
|
|
||||||
label = "".join(map(str, coeffs))
|
label = "".join(map(str, coeffs))
|
||||||
print(f"\n[{idx:02d}] (a1,a2,a3,a4) = {label}")
|
print(f"\n[{idx:02d}] (a1,a2,a3,a4) = {label}")
|
||||||
for j in range(8):
|
|
||||||
|
if target_bit == -1:
|
||||||
|
bits = range(8)
|
||||||
|
else:
|
||||||
|
if not (0 <= target_bit < 8):
|
||||||
|
raise ValueError("target_bit must be in [0, 7] or -1")
|
||||||
|
bits = [target_bit]
|
||||||
|
|
||||||
|
for j in bits:
|
||||||
poly = new_R[target_reg][j]
|
poly = new_R[target_reg][j]
|
||||||
print(f" R[{target_reg}][{j}] = {pretty_print(poly)}")
|
print(f" R[{target_reg}][{j}] = {pretty_print(poly)}")
|
||||||
|
|||||||
Reference in New Issue
Block a user