-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcisol.py
More file actions
executable file
·40 lines (25 loc) · 961 Bytes
/
cisol.py
File metadata and controls
executable file
·40 lines (25 loc) · 961 Bytes
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
#!/usr/bin/python3
from CodeGenerator import *
from argparse import *
from os import system
argp = ArgumentParser()
argp.add_argument("-f", help="File", dest="src_name")
argp.add_argument("-o", help="Output C filename", default='out.c', dest="out_name")
argp.add_argument("-b", help="Begin offset", default=0, dest="begin_off")
argp.add_argument("-e", help="End offset", default=0, dest="end_off")
argp.add_argument("-use-flags", help="Select flags to use", default='czao', dest="flags_used")
args = vars(argp.parse_args())
filename = args['src_name']
flagsUsed = [x for x in args['flags_used']]
begin, end = (int(args['begin_off'], 16), int(args['end_off'], 16) )
if filename == None:
argp.print_help()
exit(0)
cg = CodeGenerator(filename, begin, end, flagsUsed)
cCode = cg.getAsC()
out = open('out.c', 'wb')
out.write(bytes(cCode, encoding='ascii'))
out.close()
print('==== translated... ====')
print(cCode)
#system("gcc out.c -o out")