当前位置: 首页>>代码示例>>C#>>正文


C# Instruction.AddParameter方法代码示例

本文整理汇总了C#中Instruction.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Instruction.AddParameter方法的具体用法?C# Instruction.AddParameter怎么用?C# Instruction.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Instruction的用法示例。


在下文中一共展示了Instruction.AddParameter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessMovs

        private void ProcessMovs(Token[] token)
        {
            Instruction instruction;

            if(token.Length < 4 || token.Length > 5)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token.Length == 5 && token[4].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 5, token[4].Text);
            }

            if(token[1].Type == EToken.Register && token[3].Type == EToken.StackAddress)
            {
                instruction = new Instruction(EOPCode.MOVS_RegStack);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(StackAddressParam.Parse(token[3].Text));
            }
            else if(token[1].Type == EToken.StackAddress && token[3].Type == EToken.Register)
            {
                instruction = new Instruction(EOPCode.MOVS_StackReg);
                instruction.AddParameter(StackAddressParam.Parse(token[1].Text));
                instruction.AddParameter(new RegisterParam(registers[token[3].Text]));
            }
            else
            {
                throw new ParserException(line, "Invalid movs statement.");
            }

            instructions.Add(instruction);
            address += instruction.Size;
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:34,代码来源:Parser.cs

示例2: ProcessPushPop

        private void ProcessPushPop(Token[] token)
        {
            Instruction instruction;

            if(token.Length < 2 || token.Length > 3)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token.Length == 3 && token[2].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 3, token[2].Text);
            }

            if(token[1].Type == EToken.Register)
            {
                instruction = new Instruction(mnemonics[token[0].Text]);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instructions.Add(instruction);
                address += instruction.Size;
            }
            else
            {
                throw new UnexeptedTokenException(line, 2, token[2].Text);
            }
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:26,代码来源:Parser.cs

示例3: ProcessMov

        private void ProcessMov(Token[] token)
        {
            Instruction instruction = null;
            String varName;

            if(token.Length < 4 || token.Length > 5)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token[2].Type != EToken.Separator || token[2].Text != ",")
            {
                throw new UnexeptedTokenException(line, 3, token[1].Text);
            }

            if(token.Length == 5 && token[4].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 5, token[3].Text);
            }

            if(token[1].Type == EToken.Register)
            {
                if(Validators.IsWriteProtectedRegister(token[1].Text))
                {
                    throw new ParserException(line, "Cannot access write protected register.");
                }
            }

            if(token[1].Type == EToken.Register && token[3].Type == EToken.Register)
            {
                instruction = new Instruction(EOPCode.MOV_RegReg);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new RegisterParam(registers[token[3].Text]));
            }
            else if(token[1].Type == EToken.Register && token[3].Type == EToken.Address)
            {
                varName = GetVarFromAddress(token[3].Text);

                if(!variableNames.Contains(varName))
                {
                    throw new ParserException(line, String.Format("Couldn't find variable: \"{0}\"", varName));
                }

                instruction = new Instruction(EOPCode.MOV_RegAddr);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new AddressParam(variableNames.IndexOf(varName) * 4, ESegment.Data));
            }
            else if(token[1].Type == EToken.Register && token[3].Type == EToken.Number)
            {
                instruction = new Instruction(EOPCode.MOV_RegDWord);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new DWordParam(Convert.ToInt32(token[3].Text)));
            }
            else if(token[1].Type == EToken.Address && token[3].Type == EToken.Register)
            {
                if(!variableNames.Contains(token[1].Text.Substring(1, token[1].Text.Length - 2)))
                {
                    throw new ParserException(line, String.Format("Invalid address: \"{0}\"", token[1].Text));
                }

                instruction = new Instruction(EOPCode.MOV_AddrReg);
                instruction.AddParameter(new AddressParam(variableNames.IndexOf(token[1].Text.Substring(1, token[1].Text.Length - 2)) * 4, ESegment.Data));
                instruction.AddParameter(new RegisterParam(registers[token[3].Text]));
            }
            else if(token[1].Type == EToken.Register && token[3].Type == EToken.AddressFromRegister)
            {
                string source = token[3].Text.Substring(1);

                source = source.Substring(0, source.Length - 1);

                instruction = new Instruction(EOPCode.MOV_RegAddrInReg);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new RegisterParam(registers[source]));
            }
            else
            {
                throw new ParserException(line, "Invalid mov command.");
            }

            if(instruction != null)
            {
                instructions.Add(instruction);
                address += instruction.Size;
            }
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:85,代码来源:Parser.cs

示例4: ProcessJump

        private void ProcessJump(Token[] token)
        {
            Instruction instruction;

            if(token.Length < 2 || token.Length > 3)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token[1].Type != EToken.Text || !Validators.isLabel(token[1].Text) || variableNames.Contains(token[1].Text))
            {
                throw new UnexeptedTokenException(line, 2, token[1].Text);
            }

            if(token.Length == 3 && token[2].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 3, token[2].Text);
            }

            instruction = new Instruction(mnemonics[token[0].Text]);
            instruction.AddParameter(new LabelParam(token[1].Text));
            instructions.Add(instruction);
            address += instruction.Size;
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:24,代码来源:Parser.cs

示例5: ProcessIncDec

        private void ProcessIncDec(Token[] token)
        {
            Instruction instruction;

            if(token.Length < 2 || token.Length > 3)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token[1].Type != EToken.Register)
            {
                throw new UnexeptedTokenException(line, 2, token[1].Text);
            }

            if(token.Length == 3 && token[2].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 3, token[2].Text);
            }

            if(Validators.IsWriteProtectedRegister(token[1].Text))
            {
                throw new ParserException(line, "Cannot access write protected register.");
            }

            instruction = new Instruction(mnemonics[token[0].Text]);
            instructions.Add(instruction);
            instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
            address += instruction.Size;
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:29,代码来源:Parser.cs

示例6: ProcessCmp

        private void ProcessCmp(Token[] token)
        {
            Instruction instruction;
            String varName;

            if(token.Length < 4 || token.Length > 5)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token[1].Type != EToken.Register)
            {
                throw new ParserException(line, "Invalid cmp command.");
            }

            if(Validators.IsWriteProtectedRegister(token[1].Text))
            {
                throw new ParserException(line, "Cannot access write protected register.");
            }

            if(token[2].Type != EToken.Separator || token[2].Text != ",")
            {
                throw new UnexeptedTokenException(line, 3, token[2].Text);
            }

            if(token[3].Type != EToken.Address && token[3].Type != EToken.Register)
            {
                throw new ParserException(line, "Invalid cmp command.");
            }

            if(token.Length == 5 && token[4].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 5, token[4].Text);
            }

            if(token[3].Type == EToken.Register)
            {
                instruction = new Instruction(EOPCode.CMP_RegReg);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new RegisterParam(registers[token[3].Text]));
            }
            else
            {
                varName = GetVarFromAddress(token[3].Text);

                if(!variableNames.Contains(varName))
                {
                    throw new ParserException(line, String.Format("Couldn't find variable: \"{0}\"", varName));
                }

                instruction = new Instruction(EOPCode.CMP_RegAddr);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new AddressParam(variableNames.IndexOf(varName) * 4, ESegment.Data));
            }

            if(instruction != null)
            {
                instructions.Add(instruction);
                address += instruction.Size;
            }
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:61,代码来源:Parser.cs

示例7: ProcessAddSubMulDivAndOrMod

        private void ProcessAddSubMulDivAndOrMod(Token[] token)
        {
            Instruction instruction;
            int offset = 0;
            String varName;

            if(token[0].Text == "add")
            {
                offset = 3;
            }
            else if(token[0].Text == "mul")
            {
                offset = 6;
            }
            else if(token[0].Text == "div")
            {
                offset = 9;
            }
            else if(token[0].Text == "and")
            {
                offset = 12;
            }
            else if(token[0].Text == "or")
            {
                offset = 15;
            }
            else if(token[0].Text == "mod")
            {
                offset = 18;
            }

            if(token.Length < 4 || token.Length > 5)
            {
                throw new ParserException(line, "Wrong number of arguments.");
            }

            if(token[1].Type != EToken.Register)
            {
                throw new UnexeptedTokenException(line, 2, token[1].Text);
            }

            if(token[2].Type != EToken.Separator && token[2].Text != ",")
            {
                throw new UnexeptedTokenException(line, 3, token[2].Text);
            }

            if(token.Length == 5 && token[4].Type != EToken.Comment)
            {
                throw new UnexeptedTokenException(line, 3, token[2].Text);
            }

            if(token[3].Type == EToken.Register)
            {
                instruction = new Instruction(EOPCode.SUB_RegReg + offset);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new RegisterParam(registers[token[3].Text]));
            }
            else if(token[3].Type == EToken.Number)
            {
                instruction = new Instruction(EOPCode.SUB_RegDWord + offset);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new DWordParam(Convert.ToInt32(token[3].Text)));
            }
            else if(token[3].Type == EToken.Address)
            {
                varName = GetVarFromAddress(token[3].Text);

                if(!variableNames.Contains(varName))
                {
                    throw new ParserException(line, String.Format("Couldn't find variable: \"{0}\"", varName));
                }

                instruction = new Instruction(EOPCode.SUB_RegAddr + offset);
                instruction.AddParameter(new RegisterParam(registers[token[1].Text]));
                instruction.AddParameter(new AddressParam(variableNames.IndexOf(varName) * 4, ESegment.Data));
            }
            else
            {
                throw new UnexeptedTokenException(line, 4, token[3].Text);
            }

            if(instruction != null)
            {
                instructions.Add(instruction);
                address += instruction.Size;
            }
        }
开发者ID:20centaurifux,项目名称:fasm,代码行数:87,代码来源:Parser.cs


注:本文中的Instruction.AddParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。