rem: else if( ( op_code & 0xc1bf ) == 0x0039 )
context: PUHHandler( REG( a0, struct ExceptionData* ed ),            REG( a1, struct PUHData*       pd ),            REG( a6, struct Library*       MMUBase ) ){  struct ExecBase* SysBase;  int              rc = 1;  SysBase = ed->exd_SysBase;  if( ( (ULONG) ed->exd_FaultAddress & ~0x1ffUL ) != (ULONG) pd->m_Intercepted )  {    // Not for us!    return 1;  }  // Remove write-protection for us.  if( ! SetPageProperties( pd->m_SuperContext,                           MAPP_SINGLEPAGE | MAPP_REPAIRABLE,                           MAPP_INVALID | MAPP_SINGLEPAGE | MAPP_REPAIRABLE,                           (ULONG) pd->m_Intercepted, TAG_DONE ) )  {    // What to do?    return 1;  }  if( ed->exd_Flags & ( EXDF_INSTRUCTION |                         EXDF_WRITEDATAUNKNOWN |                         EXDF_MISALIGNED ) )  {    KPrintF( "Illegal flag(s): %08lx, address $%08lx\n",              ed->exd_Flags, (ULONG) ed->exd_FaultAddress );    rc = 1;  }  else  {     int    size;    ULONG  reg;    BOOL   handled;    size = (ULONG) ed->exd_NextFaultAddress - (ULONG) ed->exd_FaultAddress;    reg  = (ULONG) ed->exd_FaultAddress - (ULONG) pd->m_Intercepted;    // We must initialize handled, since it is only set to TRUE, never FALSE    handled = FALSE;    if( ed->exd_Flags & EXDF_WRITE )    {      ed->exd_Flags |= EXDF_WRITECOMPLETE;      if( size == 0 )      {        // Fake byte accesses, even though illegal        if( reg & 1 )        {          PUHWrite( reg & ~1UL, ed->exd_Data & 0x00ffUL, &handled, pd, SysBase );        }        else        {          PUHWrite( reg, ( ed->exd_Data << 8 ) & 0xff00UL, &handled, pd, SysBase );        }      }      else if( size == 1 )      {        PUHWrite( reg, ed->exd_Data & 0xffffUL, &handled, pd, SysBase );      }      else if( size == 3 )      {        PUHWrite( reg, ( ed->exd_Data >> 16 ) & 0xffffUL, &handled, pd, SysBase );        PUHWrite( reg + 2, ed->exd_Data & 0xffffUL, &handled, pd, SysBase );      }      else      {        KPrintF( "Illegal size: %ld", size );      }    }    else    {      ed->exd_Flags |= EXDF_READBACK;      if( size == 0 )      {        // Fake byte accesses, even though illegal                if( reg & 1 )        {          ed->exd_Data = PUHRead( reg & ~1UL, &handled, pd, SysBase ) & 0xffUL;        }        else        {          ed->exd_Data = PUHRead( reg, &handled, pd, SysBase ) >> 8;        }      }      else if( size == 1 )      {        ed->exd_Data = PUHRead( reg, &handled, pd, SysBase );      }      else if( size == 3 )      {        ed->exd_Data =  PUHRead( reg, &handled, pd, SysBase ) << 16;        ed->exd_Data |= PUHRead( reg + 2, &handled, pd, SysBase );      }      else      {        KPrintF( "Illegal size: %ld", size );      }    }    if( ! handled && ( pd->m_Flags & PUHF_PATCH_APPS ) )    {      if( ed->exd_ReturnPC < pd->m_ROM ||           ed->exd_ReturnPC >= ( pd->m_ROM + pd->m_ROMSize ) )//      if( cp < 10 )      {        UWORD op_code;        ULONG address;        ++cp;        KPrintF( "Unhandled hit at $%08lx\n", ed->exd_ReturnPC );                op_code = ReadWord( ed->exd_ReturnPC );        if( op_code == 0x33fc )        {          // move.w #$xxxx,$xxxxxxxx          address = ReadLong( ed->exd_ReturnPC + 4 );          if( ( address & ~0x1ffUL ) == (ULONG) pd->m_Intercepted )          {            KPrintF( "***Patched 1: 0x%08lx\n", address );            WriteLong( ed->exd_ReturnPC + 4,                        address - 0xdff000 + (ULONG) pd->m_CustomDirect );          }        }        else if( op_code == 0x23fc )        {          // move.l #$xxxxxxxx,$xxxxxxxx          address = ReadLong( ed->exd_ReturnPC + 6 );          if( ( address & ~0x1ffUL ) == (ULONG) pd->m_Intercepted )          {            KPrintF( "***Patched 2: 0x%08lx\n", address );            WriteLong( ed->exd_ReturnPC + 6,                       address - 0xdff000 + (ULONG) pd->m_CustomDirect );          }        }        else if( ( op_code & 0xcff0 ) == 0x03c0 )        {          // move.x xn,$xxxxxxxx          address = ReadLong( ed->exd_ReturnPC + 2 );          if( ( address & ~0x1ffUL ) == (ULONG) pd->m_Intercepted )          {            KPrintF( "***Patched 3: 0x%08lx\n", address );            WriteLong( ed->exd_ReturnPC + 2,                       address - 0xdff000 + (ULONG) pd->m_CustomDirect );          }        }        else if( ( op_code & 0xc1bf ) == 0x0039 )        {          // move.x xn,$xxxxxxxx          address = ReadLong( ed->exd_ReturnPC + 2 );          if( ( address & ~0x1ffUL ) == (ULONG) pd->m_Intercepted )          {            KPrintF( "***Patched 4: 0x%08lx\n", address );            WriteLong( ed->exd_ReturnPC + 2,                       address - 0xdff000 + (ULONG) pd->m_CustomDirect );          }        }      }    }    // Ok, we either emulated or simulated it;    rc = 0;  }  // Restore write-protection for us  SetPageProperties( pd->m_SuperContext,                     MAPP_INVALID | MAPP_SINGLEPAGE | MAPP_REPAIRABLE,                     MAPP_INVALID | MAPP_SINGLEPAGE | MAPP_REPAIRABLE,                     (ULONG) pd->m_Intercepted, TAG_DONE );  return rc;}