Exemplo n.º 1
0
        public static DEC Create(ILineInfo line)
        {
            if (line.NumberOfArguments != 1)
            {
                throw new Exceptions.ArgumentNumberException("DEC", line.NumberOfArguments);
            }
            var cmd = new DEC()
            {
                LineNumber = line.LineNumber
            };

            switch (line.TypeOfArgument(1))
            {
            case Lexer.ArgumentType.Register:
                cmd.Argument1 = new Register(line.Argument(1));
                cmd.Assemble  = cmd.assembleR;
                break;

            case Lexer.ArgumentType.Name:
            case Lexer.ArgumentType.Indirect:
                cmd.Argument1 = new MemoryIndirect(
                    line.NameInArgument(1),
                    line.RegistersInArgument(1),
                    line.NumbersInArgument(1),
                    line.LastCapture
                    );
                cmd.Assemble = cmd.FactoryAssemble(0xfe);
                break;
            }
            if (cmd.Assemble == null)
            {
                throw new Exceptions.ArgumentException("DEC", line.TypeOfArgument(1));
            }
            return(cmd);
        }
Exemplo n.º 2
0
        public static PUSH Create(ILineInfo line)
        {
            if (line.NumberOfArguments != 1)
            {
                throw new Exceptions.ArgumentNumberException("PUSH", line.NumberOfArguments);
            }
            var cmd = new PUSH()
            {
                LineNumber = line.LineNumber
            };
            bool isMem = false;

            switch (line.TypeOfArgument(1))
            {
            case Lexer.ArgumentType.Register:
                cmd.Argument1 = new Register(line.Argument(1));
                cmd.Assemble  = cmd.assembleR;
                break;

            case Lexer.ArgumentType.Number:
                cmd.Argument1 = new Number((Int16)line.ArgumentAsNumber(1));
                cmd.Assemble  = cmd.assembleI;
                break;

            case Lexer.ArgumentType.Name:
            case Lexer.ArgumentType.Indirect:
                cmd.Argument1 = new MemoryIndirect(
                    line.NameInArgument(1),
                    line.RegistersInArgument(1),
                    line.NumbersInArgument(1),
                    line.LastCapture
                    );
                isMem        = true;
                cmd.Assemble = cmd.assembleM;
                break;
            }
            if (cmd.Assemble == null)
            {
                throw new Exceptions.ArgumentException("PUSH", line.TypeOfArgument(1));
            }
            if (!isMem)
            {
                cmd.CheckArgumentSize();
            }
            return(cmd);
        }
Exemplo n.º 3
0
        public static MOV Create(ILineInfo line)
        {
            if (line.NumberOfArguments != 2)
            {
                throw new Exceptions.ArgumentNumberException("MOV", line.NumberOfArguments);
            }
            var cmd = new MOV()
            {
                LineNumber = line.LineNumber
            };
            bool isMem = false;

            switch (line.TypeOfArgument(1))
            {
            case Lexer.ArgumentType.Register:
                cmd.Argument1 = new Register(line.Argument(1));
                switch (line.TypeOfArgument(2))
                {
                case Lexer.ArgumentType.Register:
                    cmd.Argument2 = new Register(line.Argument(2));
                    cmd.Assemble  = cmd.FactoryAssemble(0x88);                                    //cmd.assembleRR;
                    break;

                case Lexer.ArgumentType.Number:
                    cmd.Argument2 = new Number((Int16)line.ArgumentAsNumber(2));
                    cmd.Assemble  = cmd.assembleRI;                                    //cmd.FactoryAssemble(0xc6);
                    break;

                case Lexer.ArgumentType.Name:
                case Lexer.ArgumentType.Indirect:
                    cmd.Argument2 = new MemoryIndirect(
                        line.NameInArgument(2),
                        line.RegistersInArgument(2),
                        line.NumbersInArgument(2),
                        line.LastCapture
                        );
                    cmd.Assemble = cmd.FactoryAssemble(0x8a);                                      //cmd.assembleRM;
                    isMem        = true;
                    break;
                }
                break;

            case Lexer.ArgumentType.Name:
            case Lexer.ArgumentType.Indirect:
                cmd.Argument1 = new MemoryIndirect(
                    line.NameInArgument(1),
                    line.RegistersInArgument(1),
                    line.NumbersInArgument(1),
                    line.LastCapture
                    );
                isMem = true;
                switch (line.TypeOfArgument(2))
                {
                case Lexer.ArgumentType.Register:
                    cmd.Argument2 = new Register(line.Argument(2));
                    cmd.Assemble  = cmd.FactoryAssemble(0x88);                                    //cmd.assembleMR;
                    break;

                case Lexer.ArgumentType.Number:
                    cmd.Argument2 = new Number((Int16)line.ArgumentAsNumber(2));
                    cmd.Assemble  = cmd.FactoryAssemble(0xc6);                                    //cmd.assembleMI;
                    break;
                }
                break;
            }
            if (cmd.Assemble == null)
            {
                var lastCapture = line.LastCapture;
                throw new Exceptions.ArgumentException("MOV", line.TypeOfArgument(1), line.TypeOfArgument(2), lastCapture);
            }
            if (!isMem)
            {
                cmd.CheckArgumentSize();
            }
            return(cmd);
        }
Exemplo n.º 4
0
        public static IMUL Create(ILineInfo line)
        {
            if (line.NumberOfArguments == 0 || line.NumberOfArguments > 2)
            {
                throw new Exceptions.ArgumentNumberException("IMUL", line.NumberOfArguments);
            }
            var cmd = new IMUL()
            {
                LineNumber = line.LineNumber
            };
            bool isMem = false;

            switch (line.TypeOfArgument(1))
            {
            case Lexer.ArgumentType.Register:
                cmd.Argument1 = new Register(line.Argument(1));
                switch (line.TypeOfArgument(2))
                {
                case Lexer.ArgumentType.None:
                    cmd.Assemble = cmd.FactoryAssemble1(0xf6);
                    break;

                case Lexer.ArgumentType.Register:
                    cmd.Argument2 = new Register(line.Argument(2));
                    cmd.Assemble  = cmd.FactoryAssemble2(0xaf, 0x0f);
                    break;

                case Lexer.ArgumentType.Name:
                case Lexer.ArgumentType.Indirect:
                    cmd.Argument2 = new MemoryIndirect(
                        line.NameInArgument(2),
                        line.RegistersInArgument(2),
                        line.NumbersInArgument(2),
                        line.LastCapture
                        );
                    isMem        = true;
                    cmd.Assemble = cmd.FactoryAssemble2(0xaf, 0x0f);
                    break;

                case Lexer.ArgumentType.Number:
                    cmd.Argument2 = new Number((Int16)line.ArgumentAsNumber(2));
                    cmd.Assemble  = cmd.FactoryAssemble2(0x69);
                    break;
                }
                break;

            case Lexer.ArgumentType.Name:
            case Lexer.ArgumentType.Indirect:
                cmd.Argument1 = new MemoryIndirect(
                    line.NameInArgument(1),
                    line.RegistersInArgument(1),
                    line.NumbersInArgument(1),
                    line.LastCapture
                    );
                isMem = true;
                switch (line.TypeOfArgument(2))
                {
                case Lexer.ArgumentType.None:
                    cmd.Assemble = cmd.FactoryAssemble1(0xf6);
                    break;
                }
                break;
            }
            if (cmd.Assemble == null)
            {
                var lastCapture = line.LastCapture;
                throw new Exceptions.ArgumentException("IMUL", line.TypeOfArgument(1), line.TypeOfArgument(2), lastCapture);
            }
            if (!isMem)
            {
                cmd.CheckArgumentSize();
            }
            return(cmd);
        }