aboutsummaryrefslogtreecommitdiffstats
path: root/survey.py
diff options
context:
space:
mode:
Diffstat (limited to 'survey.py')
-rwxr-xr-xsurvey.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/survey.py b/survey.py
index 69f6120..7dd32c9 100755
--- a/survey.py
+++ b/survey.py
@@ -128,7 +128,28 @@ def observe(word, pc, map):
ValueError: label reference out of range (8 bit): 'label' (0x1234)
"""
if not subv.is_reference(word):
- return word
+ if len(word) != 2:
+ return word
+
+ ref = subv.parse_immediate(word[1])
+ if not ref or "split" not in ref:
+ return word
+
+ value = word[0]
+
+ sgn = -1 if value < 0 else 1
+ value *= sgn
+
+ if ref["split"] == "hi" and ref["size"] == 20:
+ value = value >> 12
+ elif ref["split"] == "lo" and ref["size"] == 12:
+ value = value & 0xFFF
+ else:
+ raise ValueError(
+ "unknown label split mode {mode}{size}{split}".format(**ref)
+ )
+
+ return (value, "imm{size}".format(**ref))
ref = subv.parse_reference(word)