Beispiel #1
0
            private static DataResponse GetBitArrays(string[] args, CompilerEnvironment env)
            {
                var dataResponse = new DataResponse {
                    lowBitArray  = new BitArray(8),
                    highBitArray = new BitArray(8)
                    {
                        [7] = true
                    }
                };

                int address = CompilerSupport.ConvertVariableToAddress(args[0], env);

                if (address == -1)
                {
                    throw new CompilationErrorExcepton($"Переменной с именем {args[0]} не существует.", env.GetCurrentLine());
                }
                CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, address, Constants.ShortAddressBitsCount);

                int bit = CompilerSupport.ConvertToInt(args[1]);

                if (bit >= 1 << 3 || bit < 0)
                {
                    throw new CompilationErrorExcepton("Номер бита не должен превышать 7", env.GetCurrentLine());
                }
                CompilerSupport.FillBitArray(null, dataResponse.highBitArray, bit, 3);

                return(dataResponse);
            }
Beispiel #2
0
            private static DataResponse GetBitArrays(string[] args, CompilerEnvironment env)
            {
                var dataResponse = new DataResponse {
                    lowBitArray  = new BitArray(8),
                    highBitArray = new BitArray(8)
                    {
                        [5] = true,
                        [6] = true
                    }
                };

                if (args[0][0] == '#')
                {
                    int num = CompilerSupport.ConvertToInt(args[0].Substring(1));
                    CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, num, Constants.ShortAddressBitsCount);
                    dataResponse.highBitArray[4] = true;
                    return(dataResponse);
                }

                int address = CompilerSupport.ConvertVariableToAddress(args[0], env);

                if (address == -1)
                {
                    throw new CompilationErrorExcepton($"Переменной с именем {args[0]} не существует.", env.GetCurrentLine());
                }
                CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, address, Constants.ShortAddressBitsCount);
                return(dataResponse);
            }
Beispiel #3
0
            private static DataResponse GetBitArrays(string[] args, string op, CompilerEnvironment env)
            {
                if (args.Length < 0 || args.Length > 2)
                {
                    throw new CompilationErrorExcepton($"Команда {op} принимает 1 или 2 агрумента.", env.GetCurrentLine());
                }
                var dataResponse = new DataResponse {
                    lowBitArray  = new BitArray(8),
                    highBitArray = new BitArray(8)
                };

                var r = CompilerSupport.ConvertToRegister(args[0]);

                if (r.HasValue)
                {
                    return(DataResponseFromRegister(args, op, env, dataResponse, r.Value));
                }
                if (args.Length == 2)
                {
                    throw new CompilationErrorExcepton($"При работе с оперативной памятью команда {op} принимает только 1 аргумент", env.GetCurrentLine());
                }

                dataResponse.highBitArray[6] = true;
                dataResponse.highBitArray[5] = true;
                if (args[0][0] == '#')
                {
                    int num = CompilerSupport.ConvertToInt(args[0].Substring(1));
                    CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, num, Constants.ShortAddressBitsCount);
                    dataResponse.highBitArray[4] = true;
                }
                else
                {
                    var address = CompilerSupport.ConvertVariableToAddress(args[0], env);
                    CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, address, 8);
                }
                return(dataResponse);
            }
            private static DataResponse GetBitArrays(string[] args, string op, CompilerEnvironment env)
            {
                if (args.Length != 1)
                {
                    throw new CompilationErrorExcepton($"Команда {op} принимает 1 агрумент.", env.GetCurrentLine());
                }
                var dataResponse = new DataResponse {
                    lowBitArray  = new ExtendedBitArray(),
                    highBitArray = new ExtendedBitArray()
                };

                var r = CompilerSupport.ConvertToRegister(args[0]);

                if (r.HasValue)
                {
                    if (r.Value.Number > 7)
                    {
                        throw new CompilationErrorExcepton($"Номер регистра не может быть больше 7.", env.GetCurrentLine());
                    }
                    return(DataResponseFromRegister(args, op, env, dataResponse, r.Value));
                }

                dataResponse.highBitArray[6] = true;
                dataResponse.highBitArray[5] = true;
                if (args[0][0] == '#')
                {
                    int num = CompilerSupport.ConvertToInt(args[0].Substring(1));
                    CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, num, Constants.ShortAddressBitsCount);
                    dataResponse.highBitArray[4] = true;
                }
                else
                {
                    var address = CompilerSupport.ConvertVariableToAddress(args[0], env);
                    CompilerSupport.FillBitArray(null, dataResponse.lowBitArray, address, 8);
                }
                return(dataResponse);
            }