Mercurial > lcfOS
comparison python/outstream.py @ 236:8786811a5a59
Fix pcrel
author | Windel Bouwman |
---|---|
date | Mon, 15 Jul 2013 20:15:31 +0200 |
parents | ff40407c0240 |
children | 81752b0f85a5 |
comparison
equal
deleted
inserted
replaced
235:ff40407c0240 | 236:8786811a5a59 |
---|---|
46 bts = i.encode() | 46 bts = i.encode() |
47 address += len(bts) | 47 address += len(bts) |
48 | 48 |
49 def dump(self): | 49 def dump(self): |
50 self.backpatch() | 50 self.backpatch() |
51 self.backpatch() | |
51 for s in sorted(self.sections.keys()): | 52 for s in sorted(self.sections.keys()): |
52 self.dumpSection(s) | 53 self.dumpSection(s) |
53 | 54 |
54 def dumpSection(self, s): | 55 def dumpSection(self, s): |
55 print('.section '+s) | 56 print('.section '+s) |
69 | 70 |
70 class BinOutputStream(OutputStream): | 71 class BinOutputStream(OutputStream): |
71 def dump(self): | 72 def dump(self): |
72 pass | 73 pass |
73 | 74 |
75 @property | |
76 def Data(self): | |
77 d = self.dump() | |
78 return bytes(d) | |
79 | |
80 def dump(self): | |
81 self.backpatch() | |
82 self.backpatch() | |
83 section = list(self.sections.keys())[0] | |
84 return self.dumpSection(section) | |
85 | |
86 def dumpSection(self, s): | |
87 d = bytearray() | |
88 for i in self.sections[s]: | |
89 addr = i.address | |
90 insword = i.encode() | |
91 assert type(insword) is bytes | |
92 d.extend(insword) | |
93 return d | |
94 |