NumInternalProcRegs            // number of IPR registers
     };
 
+    inline bool IprIsWritable(int index)
+    {
+        return index < minReadOnlyIpr || index > maxReadOnlyIpr;
+    }
+
+    inline bool IprIsReadable(int index)
+    {
+        return index < minWriteOnlyIpr || index > maxWriteOnlyIpr;
+    }
 
     extern md_ipr_names MiscRegIndexToIpr[NumInternalProcRegs];
     extern int IprToMiscRegIndex[MaxInternalProcRegs];
 
         format HwMoveIPR {
             1: hw_mfpr({{
                 int miscRegIndex = IprToMiscRegIndex[ipr_index];
-                if(miscRegIndex < 0 ||
-                    (miscRegIndex >= MinWriteOnlyIpr &&
-                     miscRegIndex <= MaxWriteOnlyIpr))
+                if(miscRegIndex < 0 || !IprIsReadable(miscRegIndex))
                         fault = new UnimplementedOpcodeFault;
                 else
                     Ra = xc->readMiscRegWithEffect(miscRegIndex, fault);
         format HwMoveIPR {
             1: hw_mtpr({{
                 int miscRegIndex = IprToMiscRegIndex[ipr_index];
-                if(miscRegIndex < 0 ||
-                    (miscRegIndex >= MinReadOnlyIpr &&
-                     miscRegIndex <= MaxWriteOnlyIpr))
+                if(miscRegIndex < 0 || !IprIsWritable(miscRegIndex))
                         fault = new UnimplementedOpcodeFault;
                 else
                     xc->setMiscRegWithEffect(miscRegIndex, Ra);