Exemple #1
0
        /// <summary>
        /// The INDR instruction.
        /// </summary>
        byte INDR()
        {
            FetchFinished();

            var portNumber = Registers.C;
            var address    = Registers.HL;
            var value      = ProcessorAgent.ReadFromPort(portNumber);

            ProcessorAgent.WriteToMemory(address.ToUShort(), value);

            Registers.HL = address.Dec();
            var counter = Registers.B;

            counter      = counter.Dec();
            Registers.B  = counter;
            Registers.ZF = (counter == 0);
            Registers.NF = 1;
            Registers.SF = counter.GetBit(7);
            SetFlags3and5From(counter);

            if (counter != 0)
            {
                Registers.PC = Registers.PC.Sub(2);
                return(21);
            }

            return(16);
        }
Exemple #2
0
        /// <summary>
        /// The INDR instruction.
        /// </summary>
        byte INDR()
        {
            FetchFinished();

            var portNumber = Registers.C;
            var address    = Registers.HL;
            var value      = ProcessorAgent.ReadFromPort(portNumber);

            ProcessorAgent.WriteToMemory((ushort)address, value);

            Registers.HL--;
            var counter = Registers.B;

            counter      = (byte)(counter - 1);
            Registers.B  = counter;
            Registers.ZF = (counter == 0);
            Registers.NF = 1;
            Registers.SF = counter.GetBit(7);
            SetFlags3and5From(counter);

            if (counter != 0)
            {
                Registers.PC = (ushort)(Registers.PC - 2);
                return(21);
            }

            return(16);
        }
Exemple #3
0
        /// <summary>
        /// The IN A,(n) instruction.
        /// </summary>
        byte IN_A_n()
        {
            var portNumber = ProcessorAgent.FetchNextOpcode();

            FetchFinished();

            Registers.A = ProcessorAgent.ReadFromPort(portNumber);

            return(11);
        }
Exemple #4
0
        /// <summary>
        /// The IN F,(C) instruction.
        /// </summary>
        byte IN_F_C()
        {
            FetchFinished();

            var value = ProcessorAgent.ReadFromPort(Registers.C);

            Registers.SF = value.GetBit(7);
            Registers.ZF = (value == 0);
            Registers.NF = 0;
            Registers.HF = 0;
            Registers.PF = Parity[value];
            SetFlags3and5From(value);

            return(12);
        }