Annotation of nono/m680x0/m68030ccr.h, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2017 [email protected]
        !             4: //
        !             5: 
        !             6: #pragma once
        !             7: 
        !             8: struct m68030ccr
        !             9: {
        !            10:        // X フラグは、x の X_BIT が立っていれば 1
        !            11:        // N フラグは、n の N_BIT が立っていれば 1
        !            12:        // Z フラグは、z == 0 なら 1
        !            13:        // V フラグは、v の V_BIT が立っていれば 1
        !            14:        // C フラグは、c の C_BIT が立っていれば 1
        !            15:        static const uint32 X_BIT = 0x00000001;
        !            16:        static const uint32 N_BIT = 0x80000000;
        !            17:        static const uint32 V_BIT = 0x80000000;
        !            18:        static const uint32 C_BIT = 0x00000001;
        !            19: 
        !            20:        uint32 x;
        !            21:        uint32 v;
        !            22:        uint32 n;
        !            23:        union {
        !            24:                uint64 cz;
        !            25:                struct {
        !            26: #if BYTE_ORDER == LITTLE_ENDIAN
        !            27:                        uint32 z;
        !            28:                        uint32 c;
        !            29: #else
        !            30:                        uint32 c;
        !            31:                        uint32 z;
        !            32: #endif
        !            33:                } __packed;
        !            34:        };
        !            35: 
        !            36:        // フラグを立てる
        !            37:        void SetX() { x = X_BIT; }
        !            38:        void SetN() { n = N_BIT; }
        !            39:        void SetZ() { z = 0; }
        !            40:        void SetV() { v = V_BIT; }
        !            41:        void SetC() { c = C_BIT; }
        !            42: 
        !            43:        // フラグを降ろす
        !            44:        void ClrX() { x = 0; }
        !            45:        void ClrN() { n = 0; }
        !            46:        void ClrZ() { z = 1; }
        !            47:        void ClrV() { v = 0; }
        !            48:        void ClrC() { c = 0; }
        !            49: 
        !            50:        // フラグを value (bool値) にセットする
        !            51:        void PutX(bool value) { x = (value) ? X_BIT : 0; }
        !            52:        void PutN(bool value) { n = (value) ? N_BIT : 0; }
        !            53:        void PutZ(bool value) { z = (value) ? 0 : 1; }
        !            54:        void PutV(bool value) { v = (value) ? V_BIT : 0; }
        !            55:        void PutC(bool value) { c = (value) ? C_BIT : 0; }
        !            56: 
        !            57:        // フラグが立っていれば真を返す
        !            58:        bool IsX() const { return ((x & X_BIT) != 0); }
        !            59:        bool IsN() const { return ((n & N_BIT) != 0); }
        !            60:        bool IsZ() const { return (z == 0); }
        !            61:        bool IsV() const { return ((v & V_BIT) != 0); }
        !            62:        bool IsC() const { return ((c & C_BIT) != 0); }
        !            63: 
        !            64:        // CCR レジスタの内容を作って返す
        !            65:        uint8 Get() const {
        !            66:                return (IsX() ? M68K_CCR_X : 0)
        !            67:                     | (IsN() ? M68K_CCR_N : 0)
        !            68:                     | (IsZ() ? M68K_CCR_Z : 0)
        !            69:                     | (IsV() ? M68K_CCR_V : 0)
        !            70:                     | (IsC() ? M68K_CCR_C : 0);
        !            71:        }
        !            72: 
        !            73:        // CCR レジスタに val をセットする
        !            74:        void Set(uint8 val) {
        !            75:                PutX((val) & M68K_CCR_X);
        !            76:                PutN((val) & M68K_CCR_N);
        !            77:                PutZ((val) & M68K_CCR_Z);
        !            78:                PutV((val) & M68K_CCR_V);
        !            79:                PutC((val) & M68K_CCR_C);
        !            80:        }
        !            81: };
        !            82: 
        !            83: // フラグを立てる
        !            84: #define RegSetX()              cpu->reg.ccr.SetX()
        !            85: #define RegSetN()              cpu->reg.ccr.SetN()
        !            86: #define RegSetZ()              cpu->reg.ccr.SetZ()
        !            87: #define RegSetV()              cpu->reg.ccr.SetV()
        !            88: #define RegSetC()              cpu->reg.ccr.SetC()
        !            89: 
        !            90: // フラグを降ろす
        !            91: #define RegClrX()              cpu->reg.ccr.ClrX()
        !            92: #define RegClrN()              cpu->reg.ccr.ClrN()
        !            93: #define RegClrZ()              cpu->reg.ccr.ClrZ()
        !            94: #define RegClrV()              cpu->reg.ccr.ClrV()
        !            95: #define RegClrC()              cpu->reg.ccr.ClrC()
        !            96: 
        !            97: // フラグを value (bool値) にセットする
        !            98: #define RegPutX(value)         cpu->reg.ccr.PutX(value)
        !            99: #define RegPutN(value)         cpu->reg.ccr.PutN(value)
        !           100: #define RegPutZ(value)         cpu->reg.ccr.PutZ(value)
        !           101: #define RegPutV(value)         cpu->reg.ccr.PutV(value)
        !           102: #define RegPutC(value)         cpu->reg.ccr.PutC(value)
        !           103: 
        !           104: // フラグが立っていれば真を返す
        !           105: #define RegIsX                 (cpu->reg.ccr.IsX())
        !           106: #define RegIsN                 (cpu->reg.ccr.IsN())
        !           107: #define RegIsZ                 (cpu->reg.ccr.IsZ())
        !           108: #define RegIsV                 (cpu->reg.ccr.IsV())
        !           109: #define RegIsC                 (cpu->reg.ccr.IsC())
        !           110: 
        !           111: #define RegCondT       (true)
        !           112: #define RegCondF       (false)
        !           113: #define RegCondHI      (!RegIsC && !RegIsZ)
        !           114: #define RegCondLS      (RegIsC || RegIsZ)
        !           115: #define RegCondCC      (!RegIsC)
        !           116: #define RegCondCS      (RegIsC)
        !           117: #define RegCondNE      (!RegIsZ)
        !           118: #define RegCondEQ      (RegIsZ)
        !           119: #define RegCondVC      (!RegIsV)
        !           120: #define RegCondVS      (RegIsV)
        !           121: #define RegCondPL      (!RegIsN)
        !           122: #define RegCondMI      (RegIsN)
        !           123: #define RegCondGE      ((RegIsN && RegIsV) || (!RegIsN && !RegIsV))
        !           124: #define RegCondLT      ((RegIsN && !RegIsV) || (!RegIsN && RegIsV))
        !           125: #define RegCondGT      ((RegIsN && RegIsV && !RegIsZ) || \
        !           126:                         (!RegIsN && !RegIsV && !RegIsZ))
        !           127: #define RegCondLE      (RegIsZ || (RegIsN && !RegIsV) || (!RegIsN && RegIsV))

unix.superglobalmegacorp.com

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