From 853bdb6741624232a952ec3d3d3021859fb2d14d Mon Sep 17 00:00:00 2001
From: Neil Webber <neil@webber.com>
Date: Wed, 20 Sep 2023 09:10:41 -0500
Subject: [PATCH] smaller loco range in fwdword

---
 pdpasmhelper.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pdpasmhelper.py b/pdpasmhelper.py
index 25c5969..479aade 100644
--- a/pdpasmhelper.py
+++ b/pdpasmhelper.py
@@ -329,11 +329,10 @@ class InstructionBlock(PDP11InstructionAssembler, AbstractContextManager):
     def _fwdword(fref):
 
         block = fref.block
-        # see if we can recover loco this amazing hack way!
-        for loco in (0, 1, 2, -1, -2):
+        # the location to be patched is in one of three places, look for it:
+        for loco in (0, 1, 2):
             if block._instblock[fref.loc + loco] == fref:
                 break
-
         fwdoffs = block.getlabel(fref.name) - (2*fref.loc)
         block._instblock[fref.loc + loco] = fwdoffs
 
@@ -429,6 +428,8 @@ class InstructionBlock(PDP11InstructionAssembler, AbstractContextManager):
 
         return self._neg16(x)
 
+    # can't use the standard fwdword patcher because the offset
+    # needs to be divided by 2 and checked if fits within 8 bits
     def _branchpatch(self, fref):
         fwdoffs = self.getlabel(fref.name) - (2 * (fref.loc + 1))
         block = fref.block