public static RET Create(ILineInfo line) { if (line.NumberOfArguments > 1) { throw new Exceptions.ArgumentNumberException("RET", line.NumberOfArguments); } var cmd = new RET() { LineNumber = line.LineNumber }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Number: cmd.Argument1 = new Number((Int16)line.ArgumentAsNumber(1)); cmd.Assemble = cmd.assemble; break; case Lexer.ArgumentType.None: cmd.Assemble = cmd.assemble; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("RET", line.TypeOfArgument(1)); } return(cmd); }
public static INT Create(ILineInfo line) { if (line.NumberOfArguments != 1) { throw new Exceptions.ArgumentNumberException("INT", line.NumberOfArguments); } var cmd = new INT() { LineNumber = line.LineNumber }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Number: cmd.Argument1 = new Number((Int16)line.ArgumentAsNumber(1)); if (cmd.Argument1.IsWord) { throw new Exceptions.ArgumentSizeException("INT"); } cmd.Assemble = cmd.assemble; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("INT", line.TypeOfArgument(1)); } return(cmd); }
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); }
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); }
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); }