From 0ac5544b64322b55f0dab2c1dbf6582a7c4b9da0 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 17 Aug 2011 23:22:49 +0200 Subject: DREAMWEB: Emit symbolic constants for data offsets --- devtools/tasmrecover/tasm/cpp.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'devtools/tasmrecover/tasm/cpp.py') diff --git a/devtools/tasmrecover/tasm/cpp.py b/devtools/tasmrecover/tasm/cpp.py index 4ed89f650d..db7855e0d0 100644 --- a/devtools/tasmrecover/tasm/cpp.py +++ b/devtools/tasmrecover/tasm/cpp.py @@ -82,6 +82,7 @@ class cpp: self.skip_output = skip_output self.translated = [] self.proc_addr = [] + self.used_data_offsets = set() self.methods = [] self.fd.write("""%s @@ -99,11 +100,13 @@ namespace %s { if self.indirection == -1: try: offset,p,p = self.context.get_offset(name) - print "OFFSET = %d" %offset - self.indirection = 0 - return str(offset) except: pass + else: + print "OFFSET = %d" %offset + self.indirection = 0 + self.used_data_offsets.add((name,offset)) + return "offset_%s" % (name,) g = self.context.get_global(name) if isinstance(g, op.const): @@ -604,6 +607,10 @@ public: for name,addr in self.proc_addr: self.hd.write("\tstatic const uint16 addr_%s = 0x%04x;\n" %(name, addr)) + + for name,addr in self.used_data_offsets: + self.hd.write("\tstatic const uint16 offset_%s = 0x%04x;\n" %(name, addr)) + offsets = [] for k, v in self.context.get_globals().items(): if isinstance(v, op.var): -- cgit v1.2.3