summaryrefslogtreecommitdiff
path: root/romstr.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2012-10-11 18:52:54 -0500
committerBryan Bishop <kanzure@gmail.com>2012-10-11 18:52:54 -0500
commit28d0d7a995fa3d5270d4d75f18f785ea27052345 (patch)
tree4b9942fe51a0901d2a282ab35ceda0c8657b0b5d /romstr.py
parent25ece07f347135a179c93581ae303d12704113cd (diff)
get an address given a label
original-commit-id: 82f7e983068e723f99a1da85c5c36a560599abc3
Diffstat (limited to 'romstr.py')
-rw-r--r--romstr.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/romstr.py b/romstr.py
index b9c8efd..66ac507 100644
--- a/romstr.py
+++ b/romstr.py
@@ -93,6 +93,16 @@ class RomStr(str):
# load the labels from the file
self.labels = json.loads(open(filename, "r").read())
+ def get_address_for(self, label):
+ """ Returns the address of a label. This is slow and could be improved
+ dramatically.
+ """
+ label = str(label)
+ for address in self.labels.keys():
+ if self.labels[address] == label:
+ return address
+ return None
+
def length(self):
""" len(self)
"""