2023-06-17 21:41:51 +03:00
|
|
|
from BasicRegister import BasicRegister
|
|
|
|
|
|
|
|
|
|
|
|
def get_memory(variable_name: str) -> list[bool]:
|
|
|
|
while True:
|
|
|
|
input_chars: list[str] = list(input(f"Enter {variable_name}: "))
|
|
|
|
|
2023-06-18 14:52:56 +03:00
|
|
|
if all(character in ["0", "1"] for character in input_chars):
|
2023-06-17 21:41:51 +03:00
|
|
|
return [True if character == "1" else False for character in input_chars]
|
|
|
|
else:
|
|
|
|
print(f"[ERROR] The {variable_name} may contain only 1-s and 0-s!")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
reg: BasicRegister = BasicRegister(get_memory("memory"))
|
|
|
|
|
|
|
|
print(reg)
|
|
|
|
|
2023-06-18 14:52:56 +03:00
|
|
|
print(reg.left_shift())
|
2023-06-17 21:41:51 +03:00
|
|
|
print(reg)
|
|
|
|
|
2023-06-18 14:52:56 +03:00
|
|
|
print(reg.right_shift())
|
2023-06-17 21:41:51 +03:00
|
|
|
print(reg)
|