mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-05-29 00:41:29 +00:00
Merge 110d81c43d
into 99f074da27
This commit is contained in:
commit
550d4124a1
|
@ -37,6 +37,11 @@ class Listing(object):
|
|||
self.listing[-1][1].extend(vals)
|
||||
|
||||
def dump(self):
|
||||
openfiles = []
|
||||
filelines = {}
|
||||
prevline = None
|
||||
prevfile = None
|
||||
prevrow = None
|
||||
if self.filename == "-":
|
||||
out = sys.stdout
|
||||
else:
|
||||
|
@ -44,13 +49,43 @@ class Listing(object):
|
|||
for x in self.listing:
|
||||
if type(x) is str:
|
||||
print(x, file=out)
|
||||
elif type(x) is list:
|
||||
prevrow = None
|
||||
curline = x[0].split('->')[0]
|
||||
curfile, curln = curline.split(':')
|
||||
curln = int(curln)
|
||||
if not curfile in openfiles:
|
||||
openfiles.append(curfile)
|
||||
with open(curfile, 'rt') as f:
|
||||
filelines['curfile'] = f.read().splitlines()
|
||||
if not prevfile == curfile:
|
||||
prevfile = curfile
|
||||
print("Source file: %s" % curfile, file=out)
|
||||
srcline = filelines['curfile'][curln - 1].strip()
|
||||
if prevline == curline:
|
||||
print("%-32s" % (x[1]), file=out)
|
||||
else:
|
||||
prevline = curline
|
||||
print("%-32s %5d %s" % (x[1], curln, srcline), file=out)
|
||||
elif type(x) is tuple:
|
||||
prevline = None
|
||||
i = 0
|
||||
pc = x[0]
|
||||
dupestring = None
|
||||
prevrow = None
|
||||
while True:
|
||||
row = x[1][i:i + 16]
|
||||
if row == []:
|
||||
break
|
||||
if prevrow == row:
|
||||
i += 16
|
||||
if not dupestring:
|
||||
dupestring = " . . ."
|
||||
print(dupestring, file=out)
|
||||
continue
|
||||
else:
|
||||
dupestring = None
|
||||
prevrow = row
|
||||
dataline = " %04X " % (pc + i)
|
||||
dataline += (" %02X" * len(row)) % tuple(row)
|
||||
charline = ""
|
||||
|
|
|
@ -929,10 +929,10 @@ class Assembler(Pass):
|
|||
self.outputbyte(expr, env, inst_bytes)
|
||||
elif arglen == 2:
|
||||
self.outputword(expr, env, inst_bytes)
|
||||
self.listing.listInstruction(self.listing_string(env.getPC(),
|
||||
self.listing.listInstruction([node.ppt, self.listing_string(env.getPC(),
|
||||
inst_bytes,
|
||||
mode, opcode,
|
||||
val1, val2))
|
||||
val1, val2)])
|
||||
env.incPC(1 + arglen)
|
||||
self.code += 1 + arglen
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user