Example #1
0
        // Initialisierung DataTable
        public ProgramMemory(SourceParser p)
        {
            Parser = p;
            table = new DataTable("memoryTable");
            table.RowChanged += new DataRowChangeEventHandler(Row_Changed);
            Bank0 = new PicBank0(table);
            Bank1 = new PicBank1(table);
            for (int i = 0; i < 16; i++) { table.Columns.Add(i.ToString("X2"), typeof(int)); }
            table.Columns.Add("header");//paodfaf

            // Initialer Aufbau d. Tabelle
            for (int i = 0; i < 13; i++) {
                if ((i > 4) && (i < 8)) { continue; }
                string[] row = new string[17];
                row[16] = (i * 16).ToString("X2");     // Zeilenheader
                for (int j = 0; j < 16; j++) {
                    row[j] = "00";
                }
                table.Rows.Add(row);
            }
            ResetBanks();
        }
Example #2
0
        // Konstruktor: Initialisierung
        public PicSim(MainWindow win)
        {
            Win = win;
            sleepTime = 50;
            breakPoints = new bool[1024];
            Parser = new SourceParser();
            ProgMem = new ProgramMemory(Parser);
            sourceArr = new int[1024];
            // byte-oriented register operations
            InitOpCodeMap(0x0700, 0x07ff, OpType.ADDWF);
            InitOpCodeMap(0x0500, 0x05ff, OpType.ANDWF);
            InitOpCodeMap(0x0180, 0x01ff, OpType.CLRF);
            InitOpCodeMap(0x0100, 0x017f, OpType.CLRW);
            InitOpCodeMap(0x0900, 0x09ff, OpType.COMF);
            InitOpCodeMap(0x0300, 0x03ff, OpType.DECF);
            InitOpCodeMap(0x0b00, 0x0bff, OpType.DECFSZ);
            InitOpCodeMap(0x0a00, 0x0aff, OpType.INCF);
            InitOpCodeMap(0x0f00, 0x0fff, OpType.INCFSZ);
            InitOpCodeMap(0x0400, 0x04ff, OpType.IORWF);
            InitOpCodeMap(0x0800, 0x08ff, OpType.MOVF);
            InitOpCodeMap(0x0080, 0x00ff, OpType.MOVWF);
            InitOpCodeMap(0x0000, OpType.NOP);
            InitOpCodeMap(0x0020, OpType.NOP);
            InitOpCodeMap(0x0040, OpType.NOP);
            InitOpCodeMap(0x0060, OpType.NOP);
            InitOpCodeMap(0x0d00, 0x0dff, OpType.RLF);
            InitOpCodeMap(0x0c00, 0x0cff, OpType.RRF);
            InitOpCodeMap(0x0200, 0x02ff, OpType.SUBWF);
            InitOpCodeMap(0x0e00, 0x0eff, OpType.SWAPF);
            InitOpCodeMap(0x0600, 0x06ff, OpType.XORWF);

            // bit-oriented register operations
            InitOpCodeMap(0x1000, 0x13ff, OpType.BCF);
            InitOpCodeMap(0x1400, 0x17ff, OpType.BSF);
            InitOpCodeMap(0x1800, 0x1bff, OpType.BTFSC);
            InitOpCodeMap(0x1a00, 0x1fff, OpType.BTFSS);

            // literal and control operations
            InitOpCodeMap(0x3e00, 0x3fff, OpType.ADDLW);
            InitOpCodeMap(0x3900, 0x39ff, OpType.ANDLW);
            InitOpCodeMap(0x2000, 0x27ff, OpType.CALL);
            InitOpCodeMap(0x0064, OpType.CLRWDT);
            InitOpCodeMap(0x2800, 0x28ff, OpType.GOTO);
            InitOpCodeMap(0x3800, 0x38ff, OpType.IORLW);
            InitOpCodeMap(0x3000, 0x33ff, OpType.MOVLW);
            InitOpCodeMap(0x0009, OpType.RETFIE);
            InitOpCodeMap(0x3400, 0x37ff, OpType.RETLW);
            InitOpCodeMap(0x0008, OpType.RETURN);
            InitOpCodeMap(0x0063, OpType.SLEEP);
            InitOpCodeMap(0x3c00, 0x3dff, OpType.SUBLW);
            InitOpCodeMap(0x3a00, 0x3aff, OpType.XORLW);

            // function array
            OperationArr[0] = Addwf;
            OperationArr[1] = Andwf;
            OperationArr[2] = Clrf;
            OperationArr[3] = Clrw;
            OperationArr[4] = Comf;
            OperationArr[5] = Decf;
            OperationArr[6] = Decfsz;
            OperationArr[7] = Incf;
            OperationArr[8] = Incfsz;
            OperationArr[9] = Iorwf;
            OperationArr[10] = Movf;
            OperationArr[11] = Movwf;
            OperationArr[12] = Nop;
            OperationArr[13] = Rlf;
            OperationArr[14] = Rrf;
            OperationArr[15] = Subwf;
            OperationArr[16] = Swapf;
            OperationArr[17] = Xorwf;
            OperationArr[18] = Bcf;
            OperationArr[19] = Bsf;
            OperationArr[20] = Btfsc;
            OperationArr[21] = Btfss;
            OperationArr[22] = Addlw;
            OperationArr[23] = Andlw;
            OperationArr[24] = Call;
            OperationArr[25] = Clrwdt;
            OperationArr[26] = Goto;
            OperationArr[27] = Iorlw;
            OperationArr[28] = Movlw;
            OperationArr[29] = Retfie;
            OperationArr[30] = Retlw;
            OperationArr[31] = Return;
            OperationArr[32] = Sleep;
            OperationArr[33] = Sublw;
            OperationArr[34] = Xorlw;
        }