From b304d7f4a8035844cf88f7079f48e6236986a7dd Mon Sep 17 00:00:00 2001
From: Mark Pizzolato <mark@infocomm.com>
Date: Sat, 12 Mar 2016 08:04:44 -0800
Subject: [PATCH] HP3000: Bug fix for byte instruction effective addresses
 calculations with negative indexes.

Update from Dave Bryan
---
 HP3000/hp3000_cpu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/HP3000/hp3000_cpu.c b/HP3000/hp3000_cpu.c
index f66c3a8b..0e06cb95 100644
--- a/HP3000/hp3000_cpu.c
+++ b/HP3000/hp3000_cpu.c
@@ -25,6 +25,7 @@
 
    CPU          HP 3000 Series III Central Processing Unit
 
+   11-Mar-16    JDB     Fixed byte EA calculations with negative indexes
    22-Dec-15    JDB     First release version
    01-Apr-15    JDB     First successful run of MPE-V/R through account login
    11-Dec-12    JDB     Created
@@ -2457,10 +2458,10 @@ else {                                                      /* otherwise the mod
 
 if ((CIR & LSDX_MASK) == LDD_X                          /* if the mode */
   || (CIR & LSDX_MASK) == STD_X)                        /*   is double-word indexed */
-    displacement = displacement + X * 2;                /*     then add the doubled index to the displacement */
+    displacement = displacement + X * 2 & DV_MASK;      /*     then add the doubled index to the displacement */
 
 else if (mode_disp & X_FLAG)                            /* otherwise if the mode is indexed */
-    displacement = displacement + X;                    /*   then add the index to the displacement */
+    displacement = displacement + X & DV_MASK;          /*   then add the index to the displacement */
 
 if (selector == NULL)                                   /* if a word address is requested */
     base = base + displacement;                         /*   then add in the word displacement */