annotate python/ppci/assembler.py @ 341:4d204f6f7d4e devel

Rewrite of assembler parts
author Windel Bouwman
date Fri, 28 Feb 2014 18:07:14 +0100
parents c7cc54c0dfdf
children 86b02c98a717
rev   line source
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
1
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
2 import re
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
3 import pyyacc
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
4 from . import Token, CompilerError, SourceLocation
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
5 from target import Target, Label
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
6 from .asmnodes import ALabel, AInstruction, ABinop, AUnop, ASymbol, ANumber
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
7
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
8
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
9 def bit_type(value):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
10 assert value < (2**31)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
11 assert value >= 0
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
12 t = 'val32'
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
13 for n in [8, 5, 3]:
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
14 if value < (2**n):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
15 t = 'val{}'.format(n)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
16 return t
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
17
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
18 def tokenize(s, kws):
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
19 """
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
20 Tokenizer, generates an iterator that
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
21 returns tokens!
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
22
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
23 This GREAT example was taken from python re doc page!
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
24 """
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
25 tok_spec = [
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
26 ('REAL', r'\d+\.\d+'),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
27 ('HEXNUMBER', r'0x[\da-fA-F]+'),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
28 ('NUMBER', r'\d+'),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
29 ('ID', r'[A-Za-z][A-Za-z\d_]*'),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
30 ('SKIP', r'[ \t]'),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
31 ('LEESTEKEN', r':=|[\.,=:\-+*\[\]/\(\)]|>=|<=|<>|>|<|}|{'),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
32 ('STRING', r"'.*?'"),
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
33 ('COMMENT', r";.*")
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
34 ]
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
35 tok_re = '|'.join('(?P<%s>%s)' % pair for pair in tok_spec)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
36 gettok = re.compile(tok_re).match
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
37 line = 1
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
38 pos = line_start = 0
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
39 mo = gettok(s)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
40 while mo is not None:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
41 typ = mo.lastgroup
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
42 val = mo.group(typ)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
43 if typ == 'NEWLINE':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
44 line_start = pos
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
45 line += 1
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
46 elif typ != 'SKIP':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
47 if typ == 'LEESTEKEN':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
48 typ = val
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
49 elif typ == 'NUMBER':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
50 val = int(val)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
51 elif typ == 'HEXNUMBER':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
52 val = int(val[2:], 16)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
53 typ = 'NUMBER'
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
54 elif typ == 'REAL':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
55 val = float(val)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
56 elif typ == 'STRING':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
57 val = val[1:-1]
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
58 elif typ == 'ID':
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
59 if val.lower() in kws: # ['r3', 'sp', 'add', 'yield', 'r4', 'r0', 'r1', 'sub', 'r5', 'r6', 'r2']:
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
60 typ = val.lower()
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
61 col = mo.start() - line_start
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
62 loc = SourceLocation('', line, col, 0) # TODO retrieve length?
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
63 if typ == 'NUMBER':
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
64 typ = bit_type(val)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
65 yield Token(typ, val, loc)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
66 pos = mo.end()
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
67 mo = gettok(s, pos)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
68 if pos != len(s):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
69 col = pos - line_start
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
70 loc = SourceLocation('', line, col, 0)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
71 raise CompilerError('Unexpected character {0}'.format(s[pos]), loc)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
72 yield Token('EOF', pyyacc.EOF)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
73
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
74
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
75 class Lexer:
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
76 def __init__(self, src, kws):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
77 self.tokens = tokenize(src, kws)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
78 self.curTok = self.tokens.__next__()
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
79
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
80 def next_token(self):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
81 t = self.curTok
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
82 if t.typ != 'EOF':
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
83 self.curTok = self.tokens.__next__()
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
84 return t
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
85
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
86
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
87 class Parser:
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
88 def add_rule(self, prod, rhs, f):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
89 """ Helper function to add a rule, why this is required? """
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
90 if prod == 'instruction':
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
91 def f_wrap(*args):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
92 i = f(args)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
93 self.emit(i)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
94 else:
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
95 def f_wrap(*rhs):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
96 return f(rhs)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
97 self.g.add_production(prod, rhs, f_wrap)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
98
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
99 def __init__(self, kws, instruction_rules, emit):
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
100 # Construct a parser given a grammar:
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
101 tokens2 = ['ID', 'NUMBER', ',', '[', ']', ':', '+', '-', '*',
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
102 pyyacc.EPS, 'COMMENT', '{', '}',
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
103 pyyacc.EOF, 'val32', 'val8', 'val5', 'val3']
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
104 tokens2.extend(kws)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
105 self.kws = kws
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
106 g = pyyacc.Grammar(tokens2)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
107 self.g = g
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
108 # Global structure of assembly line:
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
109 g.add_production('asmline', ['asmline2'])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
110 g.add_production('asmline', ['asmline2', 'COMMENT'])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
111 g.add_production('asmline2', ['label', 'instruction'])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
112 g.add_production('asmline2', ['instruction'])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
113 g.add_production('asmline2', ['label'])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
114 g.add_production('asmline2', [])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
115 g.add_production('label', ['ID', ':'], self.p_label)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
116 #g.add_production('label', [])
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
117
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
118 # Add instruction rules for the target in question:
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
119 for prod, rhs, f in instruction_rules:
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
120 self.add_rule(prod, rhs, f)
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
121
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
122 #g.add_production('instruction', [])
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
123 g.add_production('expression', ['term'], lambda x: x)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
124 g.add_production('expression', ['expression', 'addop', 'term'], self.p_binop)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
125 g.add_production('addop', ['-'], lambda x: x.val)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
126 g.add_production('addop', ['+'], lambda x: x.val)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
127 g.add_production('mulop', ['*'], lambda x: x.val)
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
128 g.add_production('term', ['factor'], lambda x: x)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
129 g.add_production('term', ['term', 'mulop', 'factor'], self.p_binop)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
130 g.add_production('factor', ['ID'], lambda name: ASymbol(name.val))
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
131 g.add_production('factor', ['NUMBER'], lambda num: ANumber(int(num.val)))
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
132 g.start_symbol = 'asmline'
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
133 self.emit = emit
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
134 self.p = g.generate_parser()
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
135 print('length of table:', len(self.p.action_table))
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
136
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
137 # Parser handlers:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
138 def p_ins_1(self, opc, ops):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
139 ins = AInstruction(opc, ops)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
140 self.emit(ins)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
141
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
142 def p_ins_2(self, opc):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
143 self.p_ins_1(opc, [])
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
144
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
145 def p_operands_1(self, op1):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
146 return [op1]
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
147
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
148 def p_operands_2(self, ops, comma, op2):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
149 assert type(ops) is list
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
150 ops.append(op2)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
151 return ops
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
152
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
153 def p_listitems_1(self, li1):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
154 return [li1]
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
155
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
156 def p_listitems_2(self, lis, comma, li2):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
157 assert type(lis) is list
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
158 lis.append(li2)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
159 return lis
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
160
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
161 def p_list_op(self, brace_open, lst, brace_close):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
162 return AUnop('{}', lst)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
163
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
164 def p_mem_op(self, brace_open, exp, brace_close):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
165 return AUnop('[]', exp)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
166
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
167 def p_label(self, lname, cn):
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
168 lab = Label(lname.val)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
169 self.emit(lab)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
170
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
171 def p_binop(self, exp1, op, exp2):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
172 return ABinop(op, exp1, exp2)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
173
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
174 def parse(self, lexer):
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
175 self.p.parse(lexer)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
176
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
177
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
178 class Assembler:
336
d1ecc493384e Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
Windel Bouwman
parents: 334
diff changeset
179 def __init__(self, target, stream):
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
180 self.target = target
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
181 assert isinstance(target, Target)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
182 self.stream = stream
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
183 self.parser = Parser(target.asm_keywords, target.assembler_rules, self.stream.emit)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
184
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
185 # Top level interface:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
186 def parse_line(self, line):
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
187 """ Parse line into assembly instructions """
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
188 tokens = Lexer(line, self.target.asm_keywords)
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
189 self.parser.parse(tokens)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
190
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
191 def assemble(self, asmsrc):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
192 """ Assemble this source snippet """
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
193 if hasattr(asmsrc, 'read'):
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
194 asmsrc2 = asmsrc.read()
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
195 asmsrc.close()
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
196 asmsrc = asmsrc2
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
197 # TODO: use generic newline??
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
198 # TODO: the bothersome newline ...
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
199 for line in asmsrc.split('\n'):
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
200 self.parse_line(line)
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
201
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
202 def assemble_line(self, line):
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 337
diff changeset
203 """ Assemble a single assembly line. """
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
204 self.parse_line(line)