Beispiel #1
0
        private void load_xx_mmmm(IRegister <ushort> XX)
        {
            var addr = WordAtPCPlusInitialOpcodeLength;

            XX.Value = Memory.GetWordAt(addr);
            WZ.Value = addr;
            WZ.Inc();
        }
Beispiel #2
0
        private void load_mmmm_xx(IRegister <ushort> XX)
        {
            var addr = WordAtPCPlusInitialOpcodeLength;

            Memory.SetWordAt(WordAtPCPlusInitialOpcodeLength, XX.Value);
            WZ.Value = addr;
            WZ.Inc();
        }
Beispiel #3
0
        private void load_a_mmmm()
        {
            ushort addr = WordAtPCPlusInitialOpcodeLength;

            A.Value  = Memory[addr];
            WZ.Value = addr;
            WZ.Inc();
        }
Beispiel #4
0
        private void rrd()
        {
            int oldHlm = HLM.Value;
            int newHlm = (oldHlm >> 4) | (A.Value << 4);

            A.Value   = (byte)((A.Value & 0xF0) | (oldHlm & 0x0F));
            HLM.Value = (byte)newHlm;
            F.Value   = (byte)((F.Value & 0x01) | SZ53P(A.Value));

            WZ.Value = HL.Value;
            WZ.Inc();
        }
Beispiel #5
0
 private void lddr()
 {
     ldd();
     if (BC.NZ)
     {
         NextPC          -= 2;
         RecordExtraTicks = true;
     }
     else
     {
         WZ.Value = PC.Value;
         WZ.Inc();
     }
 }
Beispiel #6
0
        private void sbc_hl(IRegister <ushort> r2)
        {
            WZ.Value = HL.Value;
            WZ.Inc();

            int cfVal = CF ? 1 : 0;
            int diff  = HL.Value - r2.Value - cfVal;

            F.Value = (byte)(S_NF | (diff >> 8) & (S_SF | S_F5 | S_F3));
            HF      = ((HL.Value & 0x0FFF) - (r2.Value & 0x0FFF)) - cfVal < 0;

            VF = ((r2.Value ^ HL.Value) & (HL.Value ^ diff) & 0x8000) != 0x0000;
            ZF = diff == 0;
            CF = diff < 0;

            HL.Value = (ushort)diff;
        }
Beispiel #7
0
        private void add(IRegister <ushort> r1, IRegister <ushort> r2)
        {
            WZ.Value = r1.Value;
            WZ.Inc();

            int sum = r1.Value + r2.Value;

            F.Value = (byte)(F.Value & (S_SF | S_ZF | S_VF));

            HF = ((r1.Value & 0x0FFF) + (r2.Value & 0x0FFF)) > 0x0FFF;

            F5 = ((sum >> 8) & S_F5) == S_F5;
            F3 = ((sum >> 8) & S_F3) == S_F3;
            CF = sum > 0xFFFF;

            r1.Value = (ushort)sum;
        }
Beispiel #8
0
        private void adc_hl(IRegister <ushort> r)
        {
            WZ.Value = HL.Value;
            WZ.Inc();

            int cfVal = CF ? 1 : 0;
            int sum   = HL.Value + r.Value + cfVal;

            F.Value = (byte)((sum >> 8) & (S_SF | S_F5 | S_F3));

            HF = ((HL.Value & 0x0FFF) + (r.Value & 0x0FFF) + cfVal) > 0x0FFF;

            VF = ((HL.Value ^ r.Value ^ 0x8000) & (r.Value ^ sum) & 0x8000) == 0x8000;
            ZF = (sum & 0xFFFF) == 0;
            CF = sum > 0xFFFF;

            HL.Value = (ushort)sum;
        }
Beispiel #9
0
        private void cpxr()
        {
            /*
             * https://www.omnimaga.org/asm-language/bit-n-(hl)-flags/5/?wap2
             *
             * WZ: when BC=1 or A=(HL): exactly as CPI/R
             * In other cases WZ = PC + 1 on each step, where PC = instruction address.
             * Note since at the last execution BC=1 or A=(HL), resulting MEMPTR = PC + 1 + 1
             * (if there were not interrupts during the execution)
             */

            if (BC.NZ && !ZF)
            {
                WZ.Value = PC.Value;
                WZ.Inc();
                RecordExtraTicks = true;
                NextPC          -= 2;
                Debug.Assert(PC.Value == NextPC);
            }
        }
Beispiel #10
0
 private void cpi()
 {
     WZ.Inc();
     cpx();
     HL.Inc();
 }
Beispiel #11
0
 private void OutPortA()
 {
     OutPort(C.Value, A.Value);
     WZ.Value = BC.Value;
     WZ.Inc();
 }
Beispiel #12
0
 private void outi()
 {
     outx(true);
     WZ.Value = BC.Value;
     WZ.Inc();
 }
Beispiel #13
0
 private void InPortA()
 {
     InPortR(A);
     WZ.Value = BC.Value;
     WZ.Inc();
 }
Beispiel #14
0
 private void ini()
 {
     WZ.Value = BC.Value;
     WZ.Inc();
     inx(true);
 }