summaryrefslogtreecommitdiff
path: root/crystal.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2012-05-04 16:49:16 -0500
committerBryan Bishop <kanzure@gmail.com>2012-05-04 16:49:16 -0500
commit9522b694a728b04782d4e0777f698df82b3b8458 (patch)
tree75e9ab68b571a5a79224629f68fce52972fa1b69 /crystal.py
parent58282e9cd88d05440693248ad546f7f6a2a99657 (diff)
improve MainText.to_asm output
original-commit-id: cb0bcb77b93eebd16be8ee188e1bfb3a6a8ac80b
Diffstat (limited to 'crystal.py')
-rw-r--r--crystal.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/crystal.py b/crystal.py
index d33f89c..6e6f305 100644
--- a/crystal.py
+++ b/crystal.py
@@ -1835,9 +1835,28 @@ class MainText(TextCommand):
# whether or not to print "db " next
new_line = False
+ # whether or not there was a ", " last..
+ # this is useful outside of quotes
+ was_comma = False
+
for byte in self.bytes:
- if byte in [0x4f, 0x51, 0x55]: pass
- elif byte in [0x50, ]: pass
+ # $4f, $51 and $55 can end a line
+ if byte in [0x4f, 0x51, 0x55]:
+ assert not new_line, "can't have $4f, $51, $55 as the first character on a newline"
+
+ if in_quotes:
+ output += "\", $%.2x\n" % (byte)
+ in_quotes = False
+ new_line = True
+ elif not in_quotes:
+ if not was_comma:
+ output += ", "
+ output += "$%.2x\n" % (byte)
+ was_comma = True
+ new_line = True
+ elif byte == 0x50:
+ assert not new_line, "can't have $50 or '@' as the first character on a newline"
+ pass
# TODO