aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_asm/asm_ops.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-05-16 17:09:45 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-05-16 17:09:45 +0300
commit1045229da08fc1c8168b5ae58d54a1566eefaaac (patch)
treeab8288897c8d66dda9f60332c02022fdbccb7c2e /atk16_asm/asm_ops.py
parent230e573b26c6a59828cda7b83d3574080d887cfe (diff)
Fix bug in assembler where long jumps with jpi got aliased
Diffstat (limited to 'atk16_asm/asm_ops.py')
-rw-r--r--atk16_asm/asm_ops.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/atk16_asm/asm_ops.py b/atk16_asm/asm_ops.py
index a7ef88f..3198d4c 100644
--- a/atk16_asm/asm_ops.py
+++ b/atk16_asm/asm_ops.py
@@ -126,6 +126,10 @@ def make_jpi(meta: Meta, symbols: Symbols, imm: int | str) -> int:
"""JPI 0110 XXXI IIII IIII"""
imm_e = eval_expr(symbols, str(imm), bits=9)
imm_e = imm_e - meta.address - 1
+
+ if imm_e < -(2 ** 8) or imm_e >= 2 ** 8:
+ raise Exception(f"jpi imm value is not representable in 9 bits: {imm_e}")
+
imm_e = imm_e & (0b111111111)
word = (0b0110 << 12) + \
imm_e