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

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