diff options
author | yenatch <yenatch@gmail.com> | 2013-07-03 21:55:46 -0400 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2013-07-10 19:12:48 -0400 |
commit | f2717519a86edfde72d519d707c50ad08d146255 (patch) | |
tree | ee58e5819bad62d97019eaa6dd6f3b6ac4dfe0a4 | |
parent | 101c57b58d46048f1b76ce7522df63ead6d3289b (diff) |
wram.py: allow space definitions using constants
original-commit-id: 6765083c1cb39a93f2b0fb60a7c203725360492d
-rw-r--r-- | wram.py | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -23,17 +23,33 @@ def read_bss_sections(bss): 'start': address, 'labels': [], } + elif ':' in line: - # the only labels that don't use :s so far are enders, - # which we typically don't want to end up in the output + # rgbds allows labels without :, but prefer convention label = line[:line.find(':')] if ';' not in label: - section['labels'] += [{'label': label, 'address': address, 'length': 0}] + section['labels'] += [{ + 'label': label, + 'address': address, + 'length': 0, + }] + elif line[:3] == 'ds ': length = eval(line[3:line.find(';')].replace('$','0x')) address += length - if section['labels']: - section['labels'][-1]['length'] += length + # adjacent labels use the same space + for label in section['labels'][::-1]: + if label['length'] == 0: + label['length'] = length + else: + break + + elif 'EQU' in line: + # some space is defined using constants + name, value = line.split('EQU') + name, value = name.strip(), value.strip().replace('$','0x').replace('%','0b') + globals()[name] = eval(value) + sections.append(section) return sections |