generate machine.py file
This commit is contained in:
23
src/ram.py
23
src/ram.py
@@ -100,15 +100,22 @@ class Ram(object):
|
||||
|
||||
|
||||
### example
|
||||
input_registers = [10, 5, 1]
|
||||
# input_registers = [10, 5, 1]
|
||||
#
|
||||
# instructions = [
|
||||
# {'op': Ram.op, 'args': ('ADD', ('i', 0), ('value', 1), ('o', 2))},
|
||||
# {'op': Ram.op, 'args': ('ADD', ('value', 0), ('@', 2, 'i', 'i'), ('o', 1))},
|
||||
# ]
|
||||
|
||||
instructions = [
|
||||
{'op': Ram.op, 'args': ('ADD', ('i', 0), ('value', 1), ('o', 2))},
|
||||
{'op': Ram.op, 'args': ('ADD', ('value', 0), ('@', 2, 'i', 'i'), ('o', 1))},
|
||||
]
|
||||
# input_registers = [10, 5, 1, 2, 4]
|
||||
# instructions = [ {"op": Ram.op, "args": ('ADD', ('i', 0), ('value', 1), ('r', 0))},
|
||||
# {"op": Ram.op, "args": ('SUB', ('i', 1), ('value', 3), ('r', 1))},
|
||||
# {"op": Ram.op, "args": ('MULT', ('r', 1), ('r', 0), ('o', 1))},
|
||||
# ]
|
||||
|
||||
ram = Ram(instructions, input_registers)
|
||||
|
||||
ram.execute()
|
||||
# ram = Ram(instructions, input_registers)
|
||||
|
||||
print("Result:", ram.output_registers)
|
||||
# ram.execute()
|
||||
|
||||
# print("Result:", ram.output_registers)
|
||||
|
||||
Reference in New Issue
Block a user