Annotation of nono/m680x0/m68030core.cpp, revision 1.1.1.7

1.1       root        1: //
                      2: // nono
1.1.1.2   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
                      7: #include "m68030core.h"
1.1.1.6   root        8: #include "vectortable.h"
1.1       root        9: 
                     10: #define OP_PROTO(name) static inline void __CONCAT(op_,name)(m68kcpu *cpu)
                     11: #define OP_DEF(name)   static inline void __CONCAT(op_,name)(m68kcpu *cpu)
                     12: #define OP_FUNC(name)  __CONCAT(op_,name)(cpu)
                     13: 
                     14: #include "m68030bus.h"
                     15: #include "m68030bus.cpp"
                     16: #include "m68030excep.h"
                     17: #include "m68030ea.h"
                     18: #include "m68030acc.h"
                     19: #include "m68030ops.h"
                     20: #include "m68030mmu.h"
                     21: #include "m68030fpu.h"
                     22: #include "m68030ops.cpp"
                     23: 
1.1.1.6   root       24: // 1命令実行する。
                     25: // 戻り値は消費したサイクル数。
                     26: int
                     27: m68030_exec(m68kcpu *cpu)
1.1       root       28: {
1.1.1.6   root       29:        uint64 cycle_start = cpu->used_cycle;
1.1       root       30: 
1.1.1.6   root       31:        try {
                     32:                // 1命令版では switch-case を使うしかない。
                     33:                RegPPC = RegPC;
                     34:                cpu->flag_pi = 0;
                     35:                cpu->flag_pd = 0;
                     36:                RegIR = m68030_fetch_16(cpu);
                     37: 
                     38:                // uint16 を 6ビット右シフトしたら 1024 以上になるはずは
                     39:                // ないのだが、デフォルトでは gcc/clang どちらも律儀に
                     40:                // 1024 以上かどうか比較して分岐しようとする。
                     41:                // gcc は __assume() を入れることでこの比較・分岐を出力
                     42:                // しないようにすることが出来た(がパフォーマンスの差は
                     43:                // 見えない程度でしかなかった)。
                     44:                // clang ではどうやったら効くか不明。
                     45:                uint16 ir = RegIR >> 6;
                     46:                __assume(ir < 1024);
                     47:                switch (ir) {
1.1       root       48: #include "m68030switch.h"
                     49:                }
1.1.1.4   root       50: 
1.1.1.6   root       51:                cpu->used_cycle += cpu->cycle_nocache;
                     52:                cpu->cycle_nocache = 0;
                     53:        } catch (int vector) {
                     54:                // ここで(C++の)例外スローをキャッチするのは
                     55:                // - メモリ空間をアクセスした先でのバスエラー例外
                     56:                // - EA パース中の不当命令例外
                     57:                // のみ。それ以外の命令途中例外はその場で処理できる。
1.1.1.7 ! root       58:                if (__predict_false(gMPU->loglevel >= 2)) {
        !            59:                        const char *name = gVectorTable->GetExceptionName(vector);
        !            60:                        if (__predict_true(name)) {
        !            61:                                gMPU->putlogn("%s", name);
        !            62:                        } else {
        !            63:                                gMPU->putlogn("vector 0x%x", vector);
        !            64:                        }
        !            65:                }
1.1.1.6   root       66:                m68030_exception(cpu, vector);
                     67:        }
1.1       root       68: 
1.1.1.6   root       69:        // 外部割り込みの起動は VM 側で処理している。
1.1       root       70: 
1.1.1.6   root       71:        return cpu->used_cycle - cycle_start;
1.1       root       72: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.