-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (46 loc) · 1.2 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from ula import ULA
from menu import Menu, MenuOption
def handle_read_a(ula: ULA):
print(ula.read_register('A'))
def handle_read_b(ula: ULA):
print(ula.read_register('B'))
def handle_write_a(ula: ULA):
value = input("Insira o valor do registrador A: ")
ula.write_register('A', value)
def handle_write_b(ula: ULA):
value = input("Insira o valor do registrador B: ")
ula.write_register('B', value)
def handle_write_op(ula: ULA):
ula.print_operations()
value = input("Insira a operação: ")
ula.write_op(value)
def handle_exec_op(ula: ULA):
ula.execute_operation()
menu = Menu(
MenuOption(
message='Definir o registrador A',
callback=handle_write_a
),
MenuOption(
message='Definir o registrador B',
callback=handle_write_b
),
MenuOption(
message='Ler o registrador A',
callback=handle_read_a
),
MenuOption(
message='Ler o registrador B',
callback=handle_read_b
),
MenuOption(
message='Definir operação',
callback=handle_write_op
),
MenuOption(
message='Executar operação',
callback=handle_exec_op
),
loop=True,
)
menu.show()