aboutsummaryrefslogtreecommitdiffstats
path: root/subx.py
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-28 15:22:11 +0000
committers-ol <s-ol@users.noreply.github.com>2020-05-28 15:22:11 +0000
commit51091f7355a89aab6347523f3e3e53ed328b4dfc (patch)
treec3a11ca809ba075a8e2b37c217c6ed6278905ff2 /subx.py
parenttests, cleanup, verify.py (diff)
downloadsubv-51091f7355a89aab6347523f3e3e53ed328b4dfc.tar.gz
subv-51091f7355a89aab6347523f3e3e53ed328b4dfc.zip
survey, pack
Diffstat (limited to 'subx.py')
-rw-r--r--subx.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/subx.py b/subx.py
index ed3b184..3266403 100644
--- a/subx.py
+++ b/subx.py
@@ -13,16 +13,29 @@ def parse_instr(line):
parts = [parse_part(part) for part in parts if part != '']
return parts
+def parse_bits(line):
+ parts = []
+ for part in white.split(line):
+ if part == '':
+ continue
+
+ val, size = parse_part(part)
+ parts.append((val, int(size)))
+ return parts
+
def parse_segment(line):
parts = white.split(line)
return (parts[1], int(parts[2], 16))
+def parse_label(line):
+ return line[:-1]
+
def is_lref(part):
return isinstance(part[0], str)
-def unlabel(part, expect=None):
+def untag(part, expect=None):
if expect and part[1] != expect:
- raise ValueError("expected {} to be labelled {}", part, expect)
+ raise ValueError("expected {} to be labelled {}".format(part, expect))
return part[0]
def format_part(part):
@@ -38,7 +51,7 @@ def format_instr(inst, comment=None):
return packed
def clean(line):
- return line.strip().split('#')[0]
+ return line.strip().split('#')[0].rstrip()
def classify(line):
if line.startswith('=='): # segment