コード例 #1
0
        public static void RRF(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            byte result = (byte)(Data.GetRegister(Data.AddressResolution(f)) >> 1);

            //Add carry bit if flag is set
            if (Data.GetRegisterBit(Data.Registers.STATUS, Data.Flags.Status.C))
            {
                result += 128;
            }

            //Set carry flag for current calculation
            if ((Data.GetRegister(Data.AddressResolution(f)) & 1) == 1)
            {
                Data.SetRegisterBit(Data.Registers.STATUS, Data.Flags.Status.C, true);
            }
            else
            {
                Data.SetRegisterBit(Data.Registers.STATUS, Data.Flags.Status.C, false);
            }

            DirectionalWrite(d, f, result);
        }
コード例 #2
0
        /// <summary>
        /// Refreshes data for all UI elements BUT the file register view
        /// </summary>
        public void UpdateUIWithoutFileRegister()
        {
            View.TrisA = new ObservableCollection <bool>(Data.ByteToBoolArray(Data.GetRegister(Data.Registers.TRISA)));
            View.TrisB = new ObservableCollection <bool>(Data.ByteToBoolArray(Data.GetRegister(Data.Registers.TRISB)));
            View.PortA = new ObservableCollection <bool>(Data.ByteToBoolArray(Data.GetRegister(Data.Registers.PORTA)));
            View.PortB = new ObservableCollection <bool>(Data.ByteToBoolArray(Data.GetRegister(Data.Registers.PORTB)));
            View.TrisA.CollectionChanged += new NotifyCollectionChangedEventHandler(TrisAChanged);
            View.TrisB.CollectionChanged += new NotifyCollectionChangedEventHandler(TrisBChanged);
            View.PortA.CollectionChanged += new NotifyCollectionChangedEventHandler(PortAChanged);
            View.PortB.CollectionChanged += new NotifyCollectionChangedEventHandler(PortBChanged);
            View.Status       = new ObservableCollection <string>(Data.ByteToStringArray(Data.GetRegister(Data.Registers.STATUS)));
            View.Option       = new ObservableCollection <string>(Data.ByteToStringArray(Data.GetRegister(Data.Registers.OPTION)));
            View.Intcon       = new ObservableCollection <string>(Data.ByteToStringArray(Data.GetRegister(Data.Registers.INTCON)));
            View.StackDisplay = new ObservableCollection <string>(Data.GetStack().Select(x => x.ToString("D4")).ToArray());
            View.SFRValues[0] = Data.GetRegisterW().ToString("X2");
            View.SFRValues[1] = Data.GetRegister(Data.Registers.PCL).ToString("X2");
            View.SFRValues[2] = Data.GetRegister(Data.Registers.PCLATH).ToString("X2");
            View.SFRValues[3] = Data.GetPC().ToString("D2");
            View.SFRValues[4] = Data.GetRegister(Data.Registers.STATUS).ToString("X2");
            View.SFRValues[5] = Data.GetRegister(Data.Registers.FSR).ToString("X2");
            View.SFRValues[6] = Data.GetRegister(Data.Registers.OPTION).ToString("X2");
            View.SFRValues[7] = Data.GetRegister(Data.Registers.TMR0).ToString("X2");
            View.SFRValues[8] = "1:" + Data.GetPrePostscalerRatio();

            if (Data.GetRegisterBit(Data.Registers.OPTION, Data.Flags.Option.PSA))
            {
                View.PrePostScalerText = "Postscaler";                                                                    //Postscaler assigned to WDT
            }
            else
            {
                View.PrePostScalerText = "Prescaler";  //Prescaler assigned to TMR0
            }
            if (StepTimer.Enabled)
            {
                View.StartStopButtonText = "Stop";
            }
            else
            {
                View.StartStopButtonText = "Start";
            }


            if (Data.GetPC() < Data.GetProgram().Count)
            {
                View.SFRValues[9] = Data.InstructionLookup(Data.GetProgram()[Data.GetPC()]).ToString();
            }
            else
            {
                View.SFRValues[9] = "N/A";
            }

            View.Runtime  = Data.GetRuntime();
            View.Watchdog = Data.GetWatchdog();
            if (SourceFile != null)
            {
                HighlightSourceLine(Data.GetPC());
            }
        }
コード例 #3
0
        public static void SWAPF(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            byte result = (byte)((Data.GetRegister(Data.AddressResolution(f)) & 0x0F) << 4 | (Data.GetRegister(Data.AddressResolution(f)) & 0xF0) >> 4);;

            DirectionalWrite(d, f, result);
        }
コード例 #4
0
        public static void SUBWF(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            byte result = BitwiseSubstract(Data.GetRegister(Data.AddressResolution(f)), Data.GetRegisterW());

            DirectionalWrite(d, f, result);
        }
コード例 #5
0
        public static void ANDWF(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            byte result = (byte)(Data.GetRegisterW() & Data.GetRegister(Data.AddressResolution(f)));

            DirectionalWrite(d, f, result);
        }
コード例 #6
0
        public static void INCF(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            byte result = (byte)(Data.GetRegister(Data.AddressResolution(f)) + 1);

            CheckZFlag(result);

            DirectionalWrite(d, f, result);
        }
コード例 #7
0
        public static void GOTO(Data.Command com)
        {
            byte k1 = com.GetLowByte();
            byte k2 = (byte)(com.GetHighByte() & 7);

            byte merge = (byte)((Data.GetRegister(Data.Registers.PCLATH) & 24) + k2);

            Data.SetPCFromBytes(merge, k1);
            Data.SetPCLfromPC();
            SkipCycle();
        }
コード例 #8
0
        public static void MOVF(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            CheckZFlag(Data.GetRegister(Data.AddressResolution(f)));
            if (d != 128)
            {
                Data.SetRegisterW(Data.GetRegister(Data.AddressResolution(f)));
            }
        }
コード例 #9
0
        public static void INCFSZ(Data.Command com)
        {
            byte d = (byte)(com.GetLowByte() & 128);
            byte f = (byte)(com.GetLowByte() & 127);

            byte result = (byte)(Data.GetRegister(Data.AddressResolution(f)) + 1);

            if (result == 0)
            {
                Data.IncPC();
                SkipCycle();
            }

            DirectionalWrite(d, f, result);
        }