forked from comex/star
-
Notifications
You must be signed in to change notification settings - Fork 0
/
epor.py
23 lines (22 loc) · 781 Bytes
/
epor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os, re, sys
def foo(m):
return '#0x%x' % (int(m.group(1), 16) - int(m.group(2), 16))
limit = int(sys.argv[2])
lines = [None] * limit
for line in open(sys.argv[1]):
line = re.sub('\s*;.*$', '', line)
line = map(str.strip, line.split('\t', 2))
if len(line) < 3: continue
b, x, line = line
line = line.strip().replace('\t', ' ').replace('.w ', ' ').replace('.n ', ' ')
if not re.match('[a-z]', line): continue
m = re.match('(pop|ldm).*pc', line) or re.match('bx.*lr', line)
lines.append(line)
n = re.match('b(l|ne|eq| )', line)
if n:
lines = []
if m:
stuff = ''.join(a[:20].ljust(25) for a in lines[:-1])
print b.ljust(10), stuff, lines[-1]
#lines = []
while len(lines) > limit: lines.pop(0)