From 82f7e983068e723f99a1da85c5c36a560599abc3 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Thu, 11 Oct 2012 18:52:54 -0500 Subject: [PATCH] get an address given a label --- extras/romstr.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extras/romstr.py b/extras/romstr.py index b9c8efdbb..66ac50767 100644 --- a/extras/romstr.py +++ b/extras/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) """