M68kException.java
     1: //========================================================================================
     2: //  M68kException.java
     3: //    en:M68k exception
     4: //    ja:M68kの例外
     5: //  Copyright (C) 2003-2017 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  http://stdkmd.com/xeij/
    11: //========================================================================================
    12: 
    13: //----------------------------------------------------------------------------------------
    14: //  throwするオブジェクトは1個だけで個々の例外の情報は持たない
    15: //  例外の情報をフィールドに格納してからthrowする
    16: //  プログラムカウンタはバスエラーとアドレスエラーのときはpc0、それ以外はpcを用いる
    17: //----------------------------------------------------------------------------------------
    18: 
    19: package xeij;
    20: 
    21: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    22: 
    23: public class M68kException extends Exception {
    24: 
    25:   public static final boolean M6E_DEBUG_ERROR = false;
    26: 
    27:   //例外ベクタ番号
    28:   //  F=スタックされたPCは命令の先頭を指す
    29:   //  N=スタックされたPCは次の命令を指す
    30:   public static final int M6E_RESET_INITIAL_SSP              =  0;  //0000     012346  Reset Initial Interrupt Stack Pointer
    31:   public static final int M6E_RESET_INITIAL_PC               =  1;  //0004     012346  Reset Initial Program Counter
    32:   public static final int M6E_ACCESS_FAULT                   =  2;  //4008  F  012346  Access Fault アクセスフォルト
    33:   public static final int M6E_ADDRESS_ERROR                  =  3;  //200C  F  012346  Address Error アドレスエラー
    34:   public static final int M6E_ILLEGAL_INSTRUCTION            =  4;  //0010  F  012346  Illegal Instruction 不当命令
    35:   public static final int M6E_DIVIDE_BY_ZERO                 =  5;  //2014  N  012346  Integer Divide by Zero ゼロ除算
    36:   public static final int M6E_CHK_INSTRUCTION                =  6;  //2018  N  012346  CHK, CHK2 instructions CHK命令
    37:   public static final int M6E_TRAPV_INSTRUCTION              =  7;  //201C  N  012346  FTRAPcc, TRAPcc, TRAPV instructions TRAPV命令
    38:   public static final int M6E_PRIVILEGE_VIOLATION            =  8;  //0020  F  012346  Privilege Violation 特権違反
    39:   public static final int M6E_TRACE                          =  9;  //2024  N  012346  Trace トレース
    40:   public static final int M6E_LINE_1010_EMULATOR             = 10;  //0028  F  012346  Line 1010 Emulator (Unimplemented A-Line opcode) ライン1010エミュレータ(SXコール)
    41:   public static final int M6E_LINE_1111_EMULATOR             = 11;  //002C  F  012346  Line 1111 Emulator (Unimplemented F-Line opcode) ライン1111エミュレータ(DOSコール,FEファンクションコール)
    42:   public static final int M6E_FP_UNIMPLEMENTED_INSTRUCTION   = 11;  //202C  N  -----6  未実装浮動小数点命令
    43:   public static final int M6E_FP_DISABLED                    = 11;  //402C  N  -----6  浮動小数点無効
    44:   public static final int M6E_EMULATOR_INTERRUPT             = 12;  //0030  N  -----S  エミュレータ割り込み
    45:   public static final int M6E_COPROCESSOR_PROTOCOL_VIOLATION = 13;  //0034     ---C--  コプロセッサプロトコル違反
    46:   public static final int M6E_FORMAT_ERROR                   = 14;  //0038  F  -12346  フォーマットエラー
    47:   public static final int M6E_UNINITIALIZED_INTERRUPT        = 15;  //003C  N  012346  未初期化割り込み
    48:   public static final int M6E_SPURIOUS_INTERRUPT             = 24;  //0060  N  012346  スプリアス割り込み
    49:   public static final int M6E_LEVEL_1_INTERRUPT_AUTOVECTOR   = 25;  //0064  N  012346  レベル1割り込みオートベクタ(FDC,FDD,ハードディスク,プリンタ)
    50:   public static final int M6E_LEVEL_2_INTERRUPT_AUTOVECTOR   = 26;  //0068  N  012346  レベル2割り込みオートベクタ(拡張I/Oスロット)
    51:   public static final int M6E_LEVEL_3_INTERRUPT_AUTOVECTOR   = 27;  //006C  N  012346  レベル3割り込みオートベクタ(DMAコントローラ転送終了など)
    52:   public static final int M6E_LEVEL_4_INTERRUPT_AUTOVECTOR   = 28;  //0070  N  012346  レベル4割り込みオートベクタ(拡張I/Oスロット)
    53:   public static final int M6E_LEVEL_5_INTERRUPT_AUTOVECTOR   = 29;  //0074  N  012346  レベル5割り込みオートベクタ(SCC RS-232C,マウス)
    54:   public static final int M6E_LEVEL_6_INTERRUPT_AUTOVECTOR   = 30;  //0078  N  012346  レベル6割り込みオートベクタ(MFP 各種タイマ,KEY,同期など)
    55:   public static final int M6E_LEVEL_7_INTERRUPT_AUTOVECTOR   = 31;  //007C  N  012346  レベル7割り込みオートベクタ(NMI)
    56:   public static final int M6E_TRAP_0_INSTRUCTION_VECTOR      = 32;  //0080  N  012346  TRAP#0命令ベクタ
    57:   public static final int M6E_TRAP_1_INSTRUCTION_VECTOR      = 33;  //0084  N  012346  TRAP#1命令ベクタ(MPCM,BGDRV)
    58:   public static final int M6E_TRAP_2_INSTRUCTION_VECTOR      = 34;  //0088  N  012346  TRAP#2命令ベクタ(PCM8)
    59:   public static final int M6E_TRAP_3_INSTRUCTION_VECTOR      = 35;  //008C  N  012346  TRAP#3命令ベクタ(ZMUSIC,ZMSC3,MIDDRV)
    60:   public static final int M6E_TRAP_4_INSTRUCTION_VECTOR      = 36;  //0090  N  012346  TRAP#4命令ベクタ(MXDRV,MADRV,MLD,MCDRV)
    61:   public static final int M6E_TRAP_5_INSTRUCTION_VECTOR      = 37;  //0094  N  012346  TRAP#5命令ベクタ(CDC)
    62:   public static final int M6E_TRAP_6_INSTRUCTION_VECTOR      = 38;  //0098  N  012346  TRAP#6命令ベクタ
    63:   public static final int M6E_TRAP_7_INSTRUCTION_VECTOR      = 39;  //009C  N  012346  TRAP#7命令ベクタ
    64:   public static final int M6E_TRAP_8_INSTRUCTION_VECTOR      = 40;  //00A0  N  012346  TRAP#8命令ベクタ(ROMデバッガがブレークポイントに使用)M6E_
    65:   public static final int M6E_TRAP_9_INSTRUCTION_VECTOR      = 41;  //00A4  N  012346  TRAP#9命令ベクタ(デバッガがブレークポイントに使用)
    66:   public static final int M6E_TRAP_10_INSTRUCTION_VECTOR     = 42;  //00A8  N  012346  TRAP#10命令ベクタ(POWER OFFまたはリセット)
    67:   public static final int M6E_TRAP_11_INSTRUCTION_VECTOR     = 43;  //00AC  N  012346  TRAP#11命令ベクタ(BREAK)
    68:   public static final int M6E_TRAP_12_INSTRUCTION_VECTOR     = 44;  //00B0  N  012346  TRAP#12命令ベクタ(COPY)
    69:   public static final int M6E_TRAP_13_INSTRUCTION_VECTOR     = 45;  //00B4  N  012346  TRAP#13命令ベクタ(^C)
    70:   public static final int M6E_TRAP_14_INSTRUCTION_VECTOR     = 46;  //00B8  N  012346  TRAP#14命令ベクタ(エラー表示)
    71:   public static final int M6E_TRAP_15_INSTRUCTION_VECTOR     = 47;  //00BC  N  012346  TRAP#15命令ベクタ(IOCSコール)
    72:   public static final int M6E_FP_BRANCH_SET_UNORDERED        = 48;  //00C0  F  --CC46  浮動小数点比較不能状態での分岐またはセット
    73:   public static final int M6E_FP_INEXACT_RESULT              = 49;  //00C4  N  --CC46  浮動小数点不正確な結果
    74:   //                                                                     30C4  N
    75:   public static final int M6E_FP_DIVIDE_BY_ZERO              = 50;  //00C8  N  --CC46  浮動小数点ゼロによる除算
    76:   public static final int M6E_FP_UNDERFLOW                   = 51;  //00CC  N  --CC46  浮動小数点アンダーフロー
    77:   //                                                                     30CC  N
    78:   public static final int M6E_FP_OPERAND_ERROR               = 52;  //00D0  N  --CC46  浮動小数点オペランドエラー
    79:   //                                                                     30D0  N
    80:   public static final int M6E_FP_OVERFLOW                    = 53;  //00D4  N  --CC46  浮動小数点オーバーフロー
    81:   //                                                                     30D4  N
    82:   public static final int M6E_FP_SIGNALING_NAN               = 54;  //00D8  N  --CC46  浮動小数点シグナリングNAN
    83:   //                                                                     30D8  N
    84:   public static final int M6E_FP_UNSUPPORTED_DATA_TYPE       = 55;  //00DC  N  ----46  浮動小数点未実装データ型(pre- 非正規化数)
    85:   //                                                                     20DC  N  ----46  浮動小数点未実装データ型(パックトデシマル)
    86:   //                                                                     30DC  N  ----46  浮動小数点未実装データ型(post- 非正規化数)
    87:   public static final int M6E_MMU_CONFIGULATION_ERROR        = 56;  // 0E0  N  --M3--  MMUコンフィギュレーションエラー
    88:   public static final int M6E_MMU_ILLEGAL_OPERATION_ERROR    = 57;  // 0E4     --M---  MMU不当操作エラー
    89:   public static final int M6E_MMU_ACCESS_LEVEL_VIOLATION     = 58;  // 0E8     --M---  MMUアクセスレベル違反
    90:   //  未実装実効アドレス(MC68060)
    91:   //    ベクタ番号60、フォーマット0。PCは例外を発生させた命令
    92:   //      Fop.X #<data>,FPn
    93:   //      Fop.P #<data>,FPn
    94:   //      FMOVEM.L #<data>,#<data>,FPSR/FPIAR
    95:   //      FMOVEM.L #<data>,#<data>,FPCR/FPIAR
    96:   //      FMOVEM.L #<data>,#<data>,FPCR/FPSR
    97:   //      FMOVEM.L #<data>,#<data>,#<data>,FPCR/FPSR/FPIAR
    98:   //      FMOVEM.X <ea>,Dn
    99:   //      FMOVEM.X Dn,<ea>
   100:   public static final int M6E_UNIMPLEMENTED_EFFECTIVE        = 60;  //00F0  F  -----6  未実装実効アドレス
   101:   //  未実装整数命令(MC68060)
   102:   //    ベクタ番号61、フォーマット0。PCは例外を発生させた命令
   103:   //      MULU.L <ea>,Dh:Dl
   104:   //      MULS.L <ea>,Dh:Dl
   105:   //      DIVU.L <ea>,Dr:Dq
   106:   //      DIVS.L <ea>,Dr:Dq
   107:   //      CAS2.W Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)
   108:   //      CAS2.L Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)
   109:   //      CHK2.B <ea>,Rn
   110:   //      CHK2.W <ea>,Rn
   111:   //      CHK2.L <ea>,Rn
   112:   //      CMP2.B <ea>,Rn
   113:   //      CMP2.W <ea>,Rn
   114:   //      CMP2.L <ea>,Rn
   115:   //      CAS.W Dc,Du,<ea> (misaligned <ea>)
   116:   //      CAS.L Dc,Du,<ea> (misaligned <ea>)
   117:   //      MOVEP.W (d16,Ar),Dq
   118:   //      MOVEP.L (d16,Ar),Dq
   119:   //      MOVEP.W Dq,(d16,Ar)
   120:   //      MOVEP.L Dq,(d16,Ar)
   121:   public static final int M6E_UNIMPLEMENTED_INSTRUCTION      = 61;  //00F4  F  -----6  未実装整数命令
   122: 
   123:   public static final String[] M6E_ERROR_NAME = {
   124:     "undefined exception #0",  //0
   125:     "undefined exception #1",  //1
   126:     "Access fault",  //2
   127:     "Address error",  //3
   128:     "Illegal instruction",  //4
   129:     "Divide by zero",  //5
   130:     "CHK instruction",  //6
   131:     "Trapv instruction",  //7
   132:     "Privilege violation",  //8
   133:     "Trace",  //9
   134:     "Line 1010 emulator",  //10
   135:     "Line 1111 emulator",  //11
   136:     "Emulator interrupt",  //12
   137:     "Coprocessor protocol violation",  //13
   138:     "Format error",  //14
   139:     "Uninitialized interrupt",  //15
   140:     "undefined exception #16",  //16
   141:     "undefined exception #17",  //17
   142:     "undefined exception #18",  //18
   143:     "undefined exception #19",  //19
   144:     "undefined exception #20",  //20
   145:     "undefined exception #21",  //21
   146:     "undefined exception #22",  //22
   147:     "undefined exception #23",  //23
   148:     "Spurious interrupt",  //24
   149:     "Level 1 interrupt autovector",  //25
   150:     "Level 2 interrupt autovector",  //26
   151:     "Level 3 interrupt autovector",  //27
   152:     "Level 4 interrupt autovector",  //28
   153:     "Level 5 interrupt autovector",  //29
   154:     "Level 6 interrupt autovector",  //30
   155:     "Level 7 interrupt autovector",  //31
   156:     "TRAP #0 instruction vector",  //32
   157:     "TRAP #1 instruction vector",  //33
   158:     "TRAP #2 instruction vector",  //34
   159:     "TRAP #3 instruction vector",  //35
   160:     "TRAP #4 instruction vector",  //36
   161:     "TRAP #5 instruction vector",  //37
   162:     "TRAP #6 instruction vector",  //38
   163:     "TRAP #7 instruction vector",  //39
   164:     "TRAP #8 instruction vector",  //40
   165:     "TRAP #9 instruction vector",  //41
   166:     "TRAP #10 instruction vector",  //42
   167:     "TRAP #11 instruction vector",  //43
   168:     "TRAP #12 instruction vector",  //44
   169:     "TRAP #13 instruction vector",  //45
   170:     "TRAP #14 instruction vector",  //46
   171:     "TRAP #15 instruction vector",  //47
   172:     "FP branch/set on unordered ",  //48
   173:     "FP inexact result",  //49
   174:     "FP divide by zero",  //50
   175:     "FP underflow",  //51
   176:     "FP operand error",  //52
   177:     "FP overflow",  //53
   178:     "FP signaling NAN",  //54
   179:     "FP unsupported data type",  //55
   180:     "MMU configulation error",  //56
   181:     "MMU illegal operation error",  //57
   182:     "MMU access level violation",  //58
   183:     "undefined exception #59",  //59
   184:     "Unimplemented effective address",  //60
   185:     "Unimplemented instruction",  //61
   186:     "undefined exception #62",  //62
   187:     "undefined exception #63",  //63
   188:   };
   189: 
   190:   public static M68kException m6eSignal;  //throwする唯一のインスタンス
   191:   public static int m6eNumber;  //ベクタ番号。0~255
   192:   public static int m6eAddress;  //アクセスアドレス
   193:   public static int m6eDirection;  //転送方向。0=WRITE,1=READ
   194:   public static int m6eSize;  //オペレーションサイズ。0=BYTE,1=WORD,2=LONG
   195: 
   196:   //  MC68060のページフォルトに関する考察
   197:   //    ページフォルトが発生すると、プレデクリメントとポストインクリメントによるアドレスレジスタの変化がすべてキャンセルされる
   198:   //      MOVE.B (A0)+,(A0)+またはMOVE.B -(A0),-(A0)でソースまたはデスティネーションでページフォルトが発生したとき、
   199:   //      どの組み合わせでもA0は命令開始時の値のままアクセスフォルトハンドラに移行する
   200:   //    RTEでページフォルトを発生させた命令に復帰すると、ソースをリードするところからやり直す
   201:   //      MOVE.B <mem>,<mem>のデスティネーションのライトでページフォルトが発生したとき、ソースのリードが2回行われる
   202:   //      これはMC68060ユーザーズマニュアルの7.10 BUS SYNCHRONIZATIONに書かれており、
   203:   //      060turboでも、ページフォルトのハンドラでソースを書き換えると結果に反映されることから、リードが再実行されていることを確認できる
   204:   //      リードすると値が変化する可能性のあるデバイスから非常駐の可能性のあるページに転送するとき、MOVE.B <mem>,<mem>を使ってはいけない
   205:   //        http://cache.freescale.com/files/32bit/doc/ref_manual/MC68060UM.pdf
   206: 
   207:   //  FSLW  Fault Status Long Word
   208:   //      31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0
   209:   //    ┏━━━━━━━┯━┯━┯━┯━━━┯━━━┯━━━┯━━━━━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┯━┓
   210:   //    ┃              │MA│  │LK│  RW  │ SIZE │  TT  │    TM    │IO│PBE SBE PTA PTB IL│PF│SP│WP│TWE RE│WE│TTR BPE    SEE┃
   211:   //    ┗━━━━━━━┷━┷━┷━┷━━━┷━━━┷━━━┷━━━━━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┷━┛
   212:   public static final int M6E_FSLW_MISALIGNED         = 1 << 27;  //MA    Misaligned Access
   213:   public static final int M6E_FSLW_LOCKED             = 1 << 25;  //LK    Locked Transfer
   214:   public static final int M6E_FSLW_READ_AND_WRITE     = 3 << 23;  //RW    Read and Write
   215:   public static final int M6E_FSLW_RW_WRITE           = 1 << 23;  //        Write
   216:   public static final int M6E_FSLW_RW_READ            = 2 << 23;  //        Read
   217:   public static final int M6E_FSLW_RW_MODIFY          = 3 << 23;  //        Read-Modify-Write
   218:   public static final int M6E_FSLW_TRANSFER_SIZE      = 3 << 21;  //SIZE  Transfer Size
   219:   public static final int M6E_FSLW_SIZE_LONG          = 0 << 21;  //        Long    マニュアルが間違っているので注意
   220:   public static final int M6E_FSLW_SIZE_BYTE          = 1 << 21;  //        Byte    マニュアルが間違っているので注意
   221:   public static final int M6E_FSLW_SIZE_WORD          = 2 << 21;  //        Word    マニュアルが間違っているので注意
   222:   public static final int M6E_FSLW_SIZE_QUAD          = 3 << 21;  //        Double Precision or MOVE16
   223:   public static final int M6E_FSLW_TRANSFER_TYPE      = 3 << 19;  //TT    Transfer Type
   224:   public static final int M6E_FSLW_TT_NORMAL          = 0 << 19;  //        Normal Access
   225:   public static final int M6E_FSLW_TT_MOVE16          = 1 << 19;  //        MOVE16 Access
   226:   public static final int M6E_FSLW_TT_ALTERNATE       = 2 << 19;  //        Alternate Logical Function Code Access, Debug Access
   227:   public static final int M6E_FSLW_TT_ACKNOWLEDGE     = 3 << 19;  //        Acknowledge Access, Low-Power Stop Broadcast
   228:   public static final int M6E_FSLW_TRANSFER_MODIFIER  = 7 << 16;  //TM    Transfer Modifier
   229:   public static final int M6E_FSLW_TM_CACHE_PUSH      = 0 << 16;  //        Data Cache Push Access
   230:   public static final int M6E_FSLW_TM_USER_DATA       = 1 << 16;  //        User Data Access
   231:   public static final int M6E_FSLW_TM_USER_CODE       = 2 << 16;  //        User Code Access
   232:   public static final int M6E_FSLW_TM_MMU_DATA        = 3 << 16;  //        MMU Table Search Data Access
   233:   public static final int M6E_FSLW_TM_MMU_CODE        = 4 << 16;  //        MMU Table Search Code Access
   234:   public static final int M6E_FSLW_TM_SUPER_DATA      = 5 << 16;  //        Supervisor Data Access
   235:   public static final int M6E_FSLW_TM_SUPER_CODE      = 6 << 16;  //        Supervisor Code Access
   236:   public static final int M6E_FSLW_TM_DATA            = 1 << 16;  //        Data Access
   237:   public static final int M6E_FSLW_TM_CODE            = 2 << 16;  //        Code Access
   238:   public static final int M6E_FSLW_TM_SUPERVISOR      = 4 << 16;  //        Supervisor Access
   239:   public static final int M6E_FSLW_INSTRUCTION        = 1 << 15;  //IO    Instruction or Operand
   240:   public static final int M6E_FSLW_IOMA_FIRST         = 0 << 15 | 0 << 27;  //Fault occurred on the first access of a misaligned transfer, or to the only access of an aligned transfer
   241:   public static final int M6E_FSLW_IOMA_SECOND        = 0 << 15 | 1 << 27;  //Fault occurred on the second or later access of a misaligned transfer
   242:   public static final int M6E_FSLW_IOMA_OPWORD        = 1 << 15 | 0 << 27;  //Fault occurred on an instruction opword fetch
   243:   public static final int M6E_FSLW_IOMA_EXWORD        = 1 << 15 | 1 << 27;  //Fault occurred on a fetch of an extension word
   244:   public static final int M6E_FSLW_PUSH_BUFFER        = 1 << 14;  //PBE   Push Buffer Bus Error
   245:   public static final int M6E_FSLW_STORE_BUFFER       = 1 << 13;  //SBE   Store Buffer Bus Error
   246:   public static final int M6E_FSLW_ROOT_DESCRIPTOR    = 1 << 12;  //PTA   Pointer A Fault
   247:   public static final int M6E_FSLW_POINTER_DESCRIPTOR = 1 << 11;  //PTB   Pointer B Fault
   248:   public static final int M6E_FSLW_INDIRECT_LEVEL     = 1 << 10;  //IL    Indirect Level Fault
   249:   public static final int M6E_FSLW_PAGE_FAULT         = 1 <<  9;  //PF    Page Fault
   250:   public static final int M6E_FSLW_SUPERVISOR_PROTECT = 1 <<  8;  //SP    Supervisor Protect
   251:   public static final int M6E_FSLW_WRITE_PROTECT      = 1 <<  7;  //WP    Write Protect
   252:   public static final int M6E_FSLW_TABLE_SEARCH       = 1 <<  6;  //TWE   Bus Error on Table Search
   253:   public static final int M6E_FSLW_BUS_ERROR_ON_READ  = 1 <<  5;  //RE    Bus Error on Read
   254:   public static final int M6E_FSLW_BUS_ERROR_ON_WRITE = 1 <<  4;  //WE    Bus Error on Write
   255:   public static final int M6E_FSLW_TRANSPARENT        = 1 <<  3;  //TTR   TTR Hit
   256:   public static final int M6E_FSLW_BRANCH_PREDICTION  = 1 <<  2;  //BPE   Branch Prediction Error
   257:   public static final int M6E_FSLW_SOFTWARE_EMULATION = 1 <<  0;  //SEE   Software Emulation Error
   258: 
   259:   public static int m6eFSLW;
   260: 
   261:   //アドレスレジスタの増分
   262:   //  実効アドレスの計算でポストインクリメントまたはプレデクリメントのとき、
   263:   //  アドレスレジスタを更新してそのままにするとページフォルトを起こした命令を再実行することができない
   264:   //  MOVE.L (A0)+,(d16,A0)などでデスティネーションの実効アドレスの計算にソースの結果を反映させる必要があるので、
   265:   //  アドレスレジスタは更新しておいてページフォルトのときだけ命令開始時の値に巻き戻す
   266:   //  CMPM.L (A0)+,(A1)+やSUBX.L -(A0),-(A1)などでは複数の増分を並べるかまたは積まなければならない
   267:   //    m6eIncremented += (long) offset << (r << 3);
   268:   //  で積むことにする
   269:   //  巻き戻すとき負数に注意する
   270:   public static long m6eIncremented;
   271: 
   272:   public static final String[] M6E_FSLW_TEXT_IOMA = {
   273:     "IO=0,MA=0  First access of a misaligned transfer or only access of an aligned transfer",
   274:     "IO=0,MA=1  Second or later access of a misaligned transfer",
   275:     "IO=1,MA=0  Instruction opword fetch",
   276:     "IO=1,MA=1  Fetch of an extension word",
   277:   };
   278:   public static final String[] M6E_FSLW_TEXT_LK = {
   279:     "LK=0       Not locked",
   280:     "LK=1       Locked",
   281:   };
   282:   public static final String[] M6E_FSLW_TEXT_RW = {
   283:     "RW=0       Undefined, reserved",
   284:     "RW=1       Write",
   285:     "RW=2       Read",
   286:     "RW=3       Read-Modify-Write",
   287:   };
   288:   public static final String[] M6E_FSLW_TEXT_SIZE = {
   289:     "SIZE=0     Byte",
   290:     "SIZE=1     Word",
   291:     "SIZE=2     Long",
   292:     "SIZE=3     Double precision or MOVE16",
   293:   };
   294:   public static final String[] M6E_FSLW_TEXT_TT = {
   295:     "TT=0       Normal access",
   296:     "TT=1       MOVE16 access",
   297:     "TT=2       Alternate or debug access",
   298:     "TT=3       Acknowledge or LPSTOP broadcast",
   299:   };
   300:   public static final String[] M6E_FSLW_TEXT_TM = {
   301:     "TM=0       Data cache push access",
   302:     "TM=1       User data or MOVE16 access",
   303:     "TM=2       User code access",
   304:     "TM=3       MMU table search data access",
   305:     "TM=4       MMU table search code access",
   306:     "TM=5       Supervisor data access",
   307:     "TM=6       Supervisor code access",
   308:     "TM=7       Reserved",
   309:     //"TM=0       Logical function code 0",
   310:     //"TM=1       Debug access",
   311:     //"TM=2       Reserved",
   312:     //"TM=3       Logical function code 3",
   313:     //"TM=4       Logical function code 4",
   314:     //"TM=5       Debug pipe control mode access",
   315:     //"TM=6       Debug pipe control mode access",
   316:     //"TM=7       Logical function code 7",
   317:   };
   318:   public static final String[] M6E_FSLW_TEXT_CAUSE = {
   319:     "SEE=1      Software emulation error",  //0
   320:     "",  //1
   321:     "BPE=1      Branch prediction error",  //2
   322:     "TTR=1      TTR hit",  //3
   323:     "WE=1       Bus error on write",  //4
   324:     "RE=1       Bus error on read",  //5
   325:     "TWE=1      Bus error on table search",  //6
   326:     "WP=1       Write protect",  //7
   327:     "SP=1       Supervisor protect",  //8
   328:     "PF=1       Page fault",  //9
   329:     "IL=1       Indirect level fault",  //10
   330:     "PTB=1      Pointer B fault",  //11
   331:     "PTA=1      Pointer A fault",  //12
   332:     "SBE=1      Store buffer bus error",  //13
   333:     "PBE=1      Push buffer bus error",  //14
   334:   };
   335: 
   336:   public static String m6eToString6 () {
   337:     StringBuilder sb = new StringBuilder ();
   338:     int supervisor = m6eFSLW & M6E_FSLW_TM_SUPERVISOR;
   339:     int instruction = m6eFSLW & M6E_FSLW_TM_CODE;
   340:     if (0 <= m6eNumber && m6eNumber < M6E_ERROR_NAME.length) {
   341:       sb.append (M6E_ERROR_NAME[m6eNumber]);
   342:     } else {
   343:       sb.append ("undefined exception #").append (m6eNumber);
   344:     }
   345:     XEiJ.fmtHex8 (sb.append (" at PC=$"), XEiJ.regPC0).append ("($");
   346:     int pa = MC68060.mmuTranslatePeek (XEiJ.regPC0, supervisor, 1);
   347:     if ((XEiJ.regPC0 ^ pa) == 1) {
   348:       sb.append ("????????");
   349:     } else {
   350:       XEiJ.fmtHex8 (sb, pa);
   351:     }
   352:     XEiJ.fmtHex4 (sb.append ("), SR=$"), XEiJ.regSRT1 | XEiJ.regSRS | XEiJ.regSRI | XEiJ.regCCR);
   353:     //              111111111122222222223333333333444444444455555555556666
   354:     //    0123456789012345678901234567890123456789012345678901234567890123
   355:     if (0b0011011101000000000000000000000000000000000000000000000000000000L << m6eNumber < 0L) {  //FORMAT $2,$4
   356:       if ((m6eFSLW & (M6E_FSLW_BUS_ERROR_ON_READ | M6E_FSLW_BUS_ERROR_ON_WRITE)) != 0) {  //バスエラーのとき。m6eAddressは物理アドレス
   357:         XEiJ.fmtHex8 (sb.append ("\n  Fault or effective address is EA=($"), m6eAddress).append (')');
   358:       } else {  //バスエラーでないとき。m6eAddressは論理アドレス
   359:         XEiJ.fmtHex8 (sb.append ("\n  Fault or effective address is EA=$"), m6eAddress).append ("($");
   360:         pa = MC68060.mmuTranslatePeek (m6eAddress, supervisor, instruction);
   361:         if ((m6eAddress ^ pa) == 1) {
   362:           sb.append ("????????");
   363:         } else {
   364:           XEiJ.fmtHex8 (sb, pa);
   365:         }
   366:         sb.append (')');
   367:       }
   368:     }
   369:     if (m6eNumber == M6E_ACCESS_FAULT) {  //FORMAT $4
   370:       XEiJ.fmtHex8 (sb.append ("\n  Fault status long word is FSLW=$"), m6eFSLW);
   371:       sb.append ("\n  Fault was caused by:");
   372:       for (int i = 14; i >= 0; i--) {
   373:         if ((m6eFSLW & (1 << i)) != 0) {
   374:           sb.append ("\n    ").append (M6E_FSLW_TEXT_CAUSE[i]);
   375:         }
   376:       }
   377:       sb.append ("\n  Fault occured on:\n    ")
   378:         .append (M6E_FSLW_TEXT_IOMA[(m6eFSLW & M6E_FSLW_INSTRUCTION) >>> 15 - 1 | (m6eFSLW & M6E_FSLW_MISALIGNED) >>> 27])
   379:           .append ("\n    ").append (M6E_FSLW_TEXT_LK[(m6eFSLW & M6E_FSLW_LOCKED) >>> 25])
   380:             .append ("\n    ").append (M6E_FSLW_TEXT_RW[(m6eFSLW & M6E_FSLW_READ_AND_WRITE) >>> 23])
   381:               .append ("\n    ").append (M6E_FSLW_TEXT_SIZE[(m6eFSLW & M6E_FSLW_TRANSFER_SIZE) >>> 21])
   382:                 .append ("\n    ").append (M6E_FSLW_TEXT_TT[(m6eFSLW & M6E_FSLW_TRANSFER_TYPE) >>> 19])
   383:                   .append ("\n    ").append (M6E_FSLW_TEXT_TM[(m6eFSLW & M6E_FSLW_TRANSFER_MODIFIER) >>> 16]);
   384:     }
   385:     return sb.toString ();
   386:   }  //m6eToString6()
   387: 
   388: }  //class M68kException
   389: 
   390: 
   391: