-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (30 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
# -----------------------------------------------------------------------------
# --------------------- Operating Systems Assignment #1 -----------------------
# ---- Author: Rafael Almeida de Bem ----
# ---- Created on: 09/03/2021 (DD/MM/YYYY) ----
# -----------------------------------------------------------------------------
from __future__ import annotations
import argparse
import pathlib
from glob import iglob
from source.vm.virtual_machine import VirtualMachine
def parse_args():
parser = argparse.ArgumentParser(
description='virtual machine emulator',
epilog='star this on github: https://github.com/debemdeboas/virtual-machine'
)
parser.add_argument('programs', nargs='*', help='assembly files to be loaded and executed')
return parser.parse_args()
def main():
args = parse_args()
if len(args.programs) > 0:
files = args.programs
else:
files = iglob('example_programs/*.asm')
vm = VirtualMachine(mem_size=4096, create_shell_sock=True)
for file in files:
vm.load_from_file(pathlib.Path(file))
vm.start()
vm.join()
if __name__ == '__main__':
main()