From 200bc15b91ee00c21f7984ce76925a2a566e5163 Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Sat, 12 Oct 2019 17:18:24 +0800 Subject: [PATCH] Allow multiple instructions per line Makes command line use easier --- ppcasm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ppcasm.py b/ppcasm.py index b0b4b82..9d29c3f 100755 --- a/ppcasm.py +++ b/ppcasm.py @@ -46,14 +46,15 @@ def assemble(asm, return_labels=False): line = line.lower() # normalize case line = line.partition('#')[0] # strip comments - line_labels, line = re.match(r'^((?:\s*\w+:)*)(.*)', line).groups() + for line in line.split(';'): + line_labels, line = re.match(r'^((?:\s*\w+:)*)(.*)', line).groups() - line_labels = re.findall(r'\w+', line_labels) - line = line.strip() + line_labels = re.findall(r'\w+', line_labels) + line = line.strip() - line_list.append((lineno, offset, orig_line, line_labels, line)) + line_list.append((lineno, offset, orig_line, line_labels, line)) - if line: offset += 4 + if line: offset += 4 # Second pass: resolve labels (each instruction is 4 bytes, easy) all_labels = {}