summaryrefslogtreecommitdiff
path: root/pp2cc.py
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-12-02 18:43:48 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-12-02 18:43:48 +0000
commita6f9617bd891074bba20cc1fc220e60a226e7fb4 (patch)
treed5634a2db32c64275aa593d8a13ca066270c3ba9 /pp2cc.py
parent45f82a1acf465c8420690a578192cdabf4bc7c04 (diff)
downloadpp2cc-a6f9617bd891074bba20cc1fc220e60a226e7fb4.tar.gz
WIP for supporting ASM parsing and initialization of variables in @DATA
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-xpp2cc.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pp2cc.py b/pp2cc.py
index 6370613..ffe9ee4 100755
--- a/pp2cc.py
+++ b/pp2cc.py
@@ -30,6 +30,8 @@ __email__ = "uwretep@gmail.com"
class Logger(object):
def __init__(self):
pass
+ def info(self, message, linked_node=None):
+ self.log(message, linked_node=linked_node, type="info")
def warning(self, message, linked_node=None):
self.log(message, linked_node=linked_node, type="warning")
def error(self, message, linked_node=None):
@@ -149,14 +151,23 @@ class Parse(object):
self.codeSegment += self.parseStatement(thing, root_node)
def compileASM(self):
"""Processes lines of assembly and merge it into the output"""
- pass
+ for label in self.asm_node.labels:
+ new_label = label
+ # rename existing names
+ if label in self.labels:
+ new_label = self.uniqLbl(label)
+ self.asm_node.renameId(label, new_label)
+ self.labels.add(new_label)
+ self.codeSegment += self.asm_node.getCodeLines()
def getSource(self):
"""Retrieves the ASM source. You need to compile it first"""
output = []
output.append("@DATA")
for varName, size in self.varNames.iteritems():
padding = " " * (16 - len(varName) - 1)
- output.append(varName + padding + " DS " + str(size))
+ assert size > 0, "Size of '{}' must be at least 1".format(varName)
+ initializers = "0,".repeat(size)[0:-1]
+ output.append(varName + padding + " DW " + initializers)
output.append("")
output.append("@CODE")
# initialization of global variables