M68kException.java
     1: //========================================================================================
     2: //  M68kException.java
     3: //    en:M68k exception
     4: //    ja:M68kの例外
     5: //  Copyright (C) 2003-2025 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: //  https://stdkmd.net/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:   //特殊例外
    26:   public static final int M6E_INSTRUCTION_BREAK_POINT = -1;  //命令ブレークポイント
    27:   public static final int M6E_WAIT_EXCEPTION          = -2;  //待機例外
    28: 
    29:   //例外ベクタ番号
    30:   //  F=スタックされたPCは命令の先頭を指す
    31:   //  N=スタックされたPCは次の命令を指す
    32:   public static final int M6E_RESET_INITIAL_SSP              =  0;  //0000     012346  Reset Initial Interrupt Stack Pointer
    33:   public static final int M6E_RESET_INITIAL_PC               =  1;  //0004     012346  Reset Initial Program Counter
    34:   public static final int M6E_ACCESS_FAULT                   =  2;  //4008  F  012346  Access Fault アクセスフォルト
    35:   public static final int M6E_ADDRESS_ERROR                  =  3;  //200C  F  012346  Address Error アドレスエラー
    36:   public static final int M6E_ILLEGAL_INSTRUCTION            =  4;  //0010  F  012346  Illegal Instruction 不当命令
    37:   public static final int M6E_DIVIDE_BY_ZERO                 =  5;  //2014  N  012346  Integer Divide by Zero ゼロ除算
    38:   public static final int M6E_CHK_INSTRUCTION                =  6;  //2018  N  012346  CHK, CHK2 instructions CHK命令
    39:   public static final int M6E_TRAPV_INSTRUCTION              =  7;  //201C  N  012346  FTRAPcc, TRAPcc, TRAPV instructions TRAPV命令
    40:   public static final int M6E_PRIVILEGE_VIOLATION            =  8;  //0020  F  012346  Privilege Violation 特権違反
    41:   public static final int M6E_TRACE                          =  9;  //2024  N  012346  Trace トレース
    42:   public static final int M6E_LINE_1010_EMULATOR             = 10;  //0028  F  012346  Line 1010 Emulator (Unimplemented A-Line opcode) ライン1010エミュレータ(SXコール)
    43:   public static final int M6E_LINE_1111_EMULATOR             = 11;  //002C  F  012346  Line 1111 Emulator (Unimplemented F-Line opcode) ライン1111エミュレータ(DOSコール,FEファンクションコール)
    44:   public static final int M6E_FP_UNIMPLEMENTED_INSTRUCTION   = 11;  //202C  N  -----6  未実装浮動小数点命令
    45:   public static final int M6E_FP_DISABLED                    = 11;  //402C  N  -----6  浮動小数点無効
    46:   public static final int M6E_EMULATOR_INTERRUPT             = 12;  //0030  N  -----S  エミュレータ割り込み
    47:   public static final int M6E_COPROCESSOR_PROTOCOL_VIOLATION = 13;  //0034     ---C--  コプロセッサプロトコル違反
    48:   public static final int M6E_FORMAT_ERROR                   = 14;  //0038  F  -12346  フォーマットエラー
    49:   public static final int M6E_UNINITIALIZED_INTERRUPT        = 15;  //003C  N  012346  未初期化割り込み
    50:   public static final int M6E_SPURIOUS_INTERRUPT             = 24;  //0060  N  012346  スプリアス割り込み
    51:   public static final int M6E_LEVEL_1_INTERRUPT_AUTOVECTOR   = 25;  //0064  N  012346  レベル1割り込みオートベクタ(FDC,FDD,ハードディスク,プリンタ)
    52:   public static final int M6E_LEVEL_2_INTERRUPT_AUTOVECTOR   = 26;  //0068  N  012346  レベル2割り込みオートベクタ(拡張I/Oスロット)
    53:   public static final int M6E_LEVEL_3_INTERRUPT_AUTOVECTOR   = 27;  //006C  N  012346  レベル3割り込みオートベクタ(DMAコントローラ転送終了など)
    54:   public static final int M6E_LEVEL_4_INTERRUPT_AUTOVECTOR   = 28;  //0070  N  012346  レベル4割り込みオートベクタ(拡張I/Oスロット)
    55:   public static final int M6E_LEVEL_5_INTERRUPT_AUTOVECTOR   = 29;  //0074  N  012346  レベル5割り込みオートベクタ(SCC RS-232C,マウス)
    56:   public static final int M6E_LEVEL_6_INTERRUPT_AUTOVECTOR   = 30;  //0078  N  012346  レベル6割り込みオートベクタ(MFP 各種タイマ,KEY,同期など)
    57:   public static final int M6E_LEVEL_7_INTERRUPT_AUTOVECTOR   = 31;  //007C  N  012346  レベル7割り込みオートベクタ(NMI)
    58:   public static final int M6E_TRAP_0_INSTRUCTION_VECTOR      = 32;  //0080  N  012346  TRAP#0命令ベクタ
    59:   public static final int M6E_TRAP_1_INSTRUCTION_VECTOR      = 33;  //0084  N  012346  TRAP#1命令ベクタ(MPCM,BGDRV)
    60:   public static final int M6E_TRAP_2_INSTRUCTION_VECTOR      = 34;  //0088  N  012346  TRAP#2命令ベクタ(PCM8)
    61:   public static final int M6E_TRAP_3_INSTRUCTION_VECTOR      = 35;  //008C  N  012346  TRAP#3命令ベクタ(ZMUSIC,ZMSC3,MIDDRV)
    62:   public static final int M6E_TRAP_4_INSTRUCTION_VECTOR      = 36;  //0090  N  012346  TRAP#4命令ベクタ(MXDRV,MADRV,MLD,MCDRV)
    63:   public static final int M6E_TRAP_5_INSTRUCTION_VECTOR      = 37;  //0094  N  012346  TRAP#5命令ベクタ(CDC)
    64:   public static final int M6E_TRAP_6_INSTRUCTION_VECTOR      = 38;  //0098  N  012346  TRAP#6命令ベクタ
    65:   public static final int M6E_TRAP_7_INSTRUCTION_VECTOR      = 39;  //009C  N  012346  TRAP#7命令ベクタ
    66:   public static final int M6E_TRAP_8_INSTRUCTION_VECTOR      = 40;  //00A0  N  012346  TRAP#8命令ベクタ(ROMデバッガがブレークポイントに使用)M6E_
    67:   public static final int M6E_TRAP_9_INSTRUCTION_VECTOR      = 41;  //00A4  N  012346  TRAP#9命令ベクタ(デバッガがブレークポイントに使用)
    68:   public static final int M6E_TRAP_10_INSTRUCTION_VECTOR     = 42;  //00A8  N  012346  TRAP#10命令ベクタ(POWER OFFまたはリセット)
    69:   public static final int M6E_TRAP_11_INSTRUCTION_VECTOR     = 43;  //00AC  N  012346  TRAP#11命令ベクタ(BREAK)
    70:   public static final int M6E_TRAP_12_INSTRUCTION_VECTOR     = 44;  //00B0  N  012346  TRAP#12命令ベクタ(COPY)
    71:   public static final int M6E_TRAP_13_INSTRUCTION_VECTOR     = 45;  //00B4  N  012346  TRAP#13命令ベクタ(^C)
    72:   public static final int M6E_TRAP_14_INSTRUCTION_VECTOR     = 46;  //00B8  N  012346  TRAP#14命令ベクタ(エラー表示)
    73:   public static final int M6E_TRAP_15_INSTRUCTION_VECTOR     = 47;  //00BC  N  012346  TRAP#15命令ベクタ(IOCSコール)
    74:   public static final int M6E_FP_BRANCH_SET_UNORDERED        = 48;  //00C0  F  --CC46  浮動小数点比較不能状態での分岐またはセット
    75:   public static final int M6E_FP_INEXACT_RESULT              = 49;  //00C4  N  --CC46  浮動小数点不正確な結果
    76:   //                                                                     30C4  N
    77:   public static final int M6E_FP_DIVIDE_BY_ZERO              = 50;  //00C8  N  --CC46  浮動小数点ゼロによる除算
    78:   public static final int M6E_FP_UNDERFLOW                   = 51;  //00CC  N  --CC46  浮動小数点アンダーフロー
    79:   //                                                                     30CC  N
    80:   public static final int M6E_FP_OPERAND_ERROR               = 52;  //00D0  N  --CC46  浮動小数点オペランドエラー
    81:   //                                                                     30D0  N
    82:   public static final int M6E_FP_OVERFLOW                    = 53;  //00D4  N  --CC46  浮動小数点オーバーフロー
    83:   //                                                                     30D4  N
    84:   public static final int M6E_FP_SIGNALING_NAN               = 54;  //00D8  N  --CC46  浮動小数点シグナリングNAN
    85:   //                                                                     30D8  N
    86:   public static final int M6E_FP_UNSUPPORTED_DATA_TYPE       = 55;  //00DC  N  ----46  浮動小数点未実装データ型(pre- 非正規化数)
    87:   //                                                                     20DC  N  ----46  浮動小数点未実装データ型(パックトデシマル)
    88:   //                                                                     30DC  N  ----46  浮動小数点未実装データ型(post- 非正規化数)
    89:   public static final int M6E_MMU_CONFIGULATION_ERROR        = 56;  // 0E0  N  --M3--  MMUコンフィギュレーションエラー
    90:   public static final int M6E_MMU_ILLEGAL_OPERATION_ERROR    = 57;  // 0E4     --M---  MMU不当操作エラー
    91:   public static final int M6E_MMU_ACCESS_LEVEL_VIOLATION     = 58;  // 0E8     --M---  MMUアクセスレベル違反
    92:   //  未実装実効アドレス(MC68060)
    93:   //    ベクタ番号60、フォーマット0。PCは例外を発生させた命令
    94:   //      Fop.X #<data>,FPn
    95:   //      Fop.P #<data>,FPn
    96:   //      FMOVEM.L #<data>,#<data>,FPSR/FPIAR
    97:   //      FMOVEM.L #<data>,#<data>,FPCR/FPIAR
    98:   //      FMOVEM.L #<data>,#<data>,FPCR/FPSR
    99:   //      FMOVEM.L #<data>,#<data>,#<data>,FPCR/FPSR/FPIAR
   100:   //      FMOVEM.X <ea>,Dn
   101:   //      FMOVEM.X Dn,<ea>
   102:   public static final int M6E_UNIMPLEMENTED_EFFECTIVE        = 60;  //00F0  F  -----6  未実装実効アドレス
   103:   //  未実装整数命令(MC68060)
   104:   //    ベクタ番号61、フォーマット0。PCは例外を発生させた命令
   105:   //      MULU.L <ea>,Dh:Dl
   106:   //      MULS.L <ea>,Dh:Dl
   107:   //      DIVU.L <ea>,Dr:Dq
   108:   //      DIVS.L <ea>,Dr:Dq
   109:   //      CAS2.W Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)
   110:   //      CAS2.L Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)
   111:   //      CHK2.B <ea>,Rn
   112:   //      CHK2.W <ea>,Rn
   113:   //      CHK2.L <ea>,Rn
   114:   //      CMP2.B <ea>,Rn
   115:   //      CMP2.W <ea>,Rn
   116:   //      CMP2.L <ea>,Rn
   117:   //      CAS.W Dc,Du,<ea> (misaligned <ea>)
   118:   //      CAS.L Dc,Du,<ea> (misaligned <ea>)
   119:   //      MOVEP.W (d16,Ar),Dq
   120:   //      MOVEP.L (d16,Ar),Dq
   121:   //      MOVEP.W Dq,(d16,Ar)
   122:   //      MOVEP.L Dq,(d16,Ar)
   123:   public static final int M6E_UNIMPLEMENTED_INSTRUCTION      = 61;  //00F4  F  -----6  未実装整数命令
   124: 
   125:   public static final String[] M6E_ERROR_NAME = {
   126:     "undefined exception #0",  //0
   127:     "undefined exception #1",  //1
   128:     "Access fault",  //2
   129:     "Address error",  //3
   130:     "Illegal instruction",  //4
   131:     "Divide by zero",  //5
   132:     "CHK instruction",  //6
   133:     "Trapv instruction",  //7
   134:     "Privilege violation",  //8
   135:     "Trace",  //9
   136:     "Line 1010 emulator",  //10
   137:     "Line 1111 emulator",  //11
   138:     "Emulator interrupt",  //12
   139:     "Coprocessor protocol violation",  //13
   140:     "Format error",  //14
   141:     "Uninitialized interrupt",  //15
   142:     "undefined exception #16",  //16
   143:     "undefined exception #17",  //17
   144:     "undefined exception #18",  //18
   145:     "undefined exception #19",  //19
   146:     "undefined exception #20",  //20
   147:     "undefined exception #21",  //21
   148:     "undefined exception #22",  //22
   149:     "undefined exception #23",  //23
   150:     "Spurious interrupt",  //24
   151:     "Level 1 interrupt autovector",  //25
   152:     "Level 2 interrupt autovector",  //26
   153:     "Level 3 interrupt autovector",  //27
   154:     "Level 4 interrupt autovector",  //28
   155:     "Level 5 interrupt autovector",  //29
   156:     "Level 6 interrupt autovector",  //30
   157:     "Level 7 interrupt autovector",  //31
   158:     "TRAP #0 instruction vector",  //32
   159:     "TRAP #1 instruction vector",  //33
   160:     "TRAP #2 instruction vector",  //34
   161:     "TRAP #3 instruction vector",  //35
   162:     "TRAP #4 instruction vector",  //36
   163:     "TRAP #5 instruction vector",  //37
   164:     "TRAP #6 instruction vector",  //38
   165:     "TRAP #7 instruction vector",  //39
   166:     "TRAP #8 instruction vector",  //40
   167:     "TRAP #9 instruction vector",  //41
   168:     "TRAP #10 instruction vector",  //42
   169:     "TRAP #11 instruction vector",  //43
   170:     "TRAP #12 instruction vector",  //44
   171:     "TRAP #13 instruction vector",  //45
   172:     "TRAP #14 instruction vector",  //46
   173:     "TRAP #15 instruction vector",  //47
   174:     "FP branch/set on unordered ",  //48
   175:     "FP inexact result",  //49
   176:     "FP divide by zero",  //50
   177:     "FP underflow",  //51
   178:     "FP operand error",  //52
   179:     "FP overflow",  //53
   180:     "FP signaling NAN",  //54
   181:     "FP unsupported data type",  //55
   182:     "MMU configulation error",  //56
   183:     "MMU illegal operation error",  //57
   184:     "MMU access level violation",  //58
   185:     "undefined exception #59",  //59
   186:     "Unimplemented effective address",  //60
   187:     "Unimplemented instruction",  //61
   188:     "undefined exception #62",  //62
   189:     "undefined exception #63",  //63
   190:   };
   191: 
   192:   public static M68kException m6eSignal;  //throwする唯一のインスタンス
   193:   public static int m6eNumber;  //ベクタ番号。0~255
   194:   public static int m6eAddress;  //アクセスアドレス
   195:   public static int m6eDirection;  //転送方向。0=WRITE,1=READ
   196:   public static int m6eSize;  //オペレーションサイズ。0=BYTE,1=WORD,2=LONG
   197: 
   198: }  //class M68kException
   199: 
   200: 
   201: