Ejemplo n.º 1
0
        private B2Instruction GenerateB2Instruction(string instructionName, string[] arguments)
        {
            if (arguments.Length != Constants.ExpectedArgumentsForInstructionClassB2)
            {
                throw new ArgumentException(
                          $"Expected {Constants.ExpectedArgumentsForInstructionClassB2} arguments, received {arguments.Length}");
            }

            var argument = arguments[0];

            ArgumentAnalyzer.GetInformationFromArgument(
                argument,
                out var addressMode,
                out var value,
                out var extendedData
                );

            if (addressMode == AddressMode.Immediate)
            {
                throw new InvalidOperationException("Destination cannot be an immediate value");
            }

            var instruction = new B2Instruction();

            instruction.InstructionNumber = b2InstructionNumbers[instructionName];
            instruction.AddressMode       = addressMode;
            instruction.Value             = value;
            instruction.DataExtension     = extendedData;

            return(instruction);
        }
Ejemplo n.º 2
0
        private B3Instruction GenerateB3Instruction(string instructionName, string[] arguments)
        {
            if (arguments.Length != Constants.ExpectedArgumentsForInstructionClassB3)
            {
                throw new ArgumentException(
                          $"Expected {Constants.ExpectedArgumentsForInstructionClassB3} arguments, received {arguments.Length}");
            }

            var argument = arguments[0];

            ArgumentAnalyzer.GetInformationFromArgument(
                argument,
                out var addressMode,
                out var value,
                out var extendedData
                );

            var instruction = new B3Instruction();

            instruction.InstructionNumber = b3InstructionNumbers[instructionName];
            instruction.Offset            = value.LoByte;
            instruction.DataExtension     = extendedData;

            return(instruction);
        }
Ejemplo n.º 3
0
        private B1Instruction GenerateB1Instruction(string instructionName, string[] arguments)
        {
            if (arguments.Length != Constants.ExpectedArgumentsForInstructionClassB1)
            {
                throw new ArgumentException(
                          $"Expected {Constants.ExpectedArgumentsForInstructionClassB1} arguments, received {arguments.Length}");
            }

            var destination = arguments[0];
            var source      = arguments[1];

            ArgumentAnalyzer.GetInformationFromArgument(
                source,
                out var sourceAddressMode,
                out var sourceValue,
                out var sourceExtendedData
                );

            ArgumentAnalyzer.GetInformationFromArgument(
                destination,
                out var destinationAddressMode,
                out var destinationValue,
                out var destinationExtendedData
                );

            if (destinationAddressMode == AddressMode.Immediate)
            {
                throw new InvalidOperationException("Destination cannot be an immediate value");
            }

            var instruction = new B1Instruction();

            instruction.InstructionNumber = b1InstructionNumbers[instructionName];

            instruction.SourceAddressMode = sourceAddressMode;
            instruction.Source            = sourceValue;

            instruction.DestinationAddressMode = destinationAddressMode;
            instruction.Destination            = destinationValue;

            instruction.SourceDataExtension      = sourceExtendedData;
            instruction.DestinationDataExtension = destinationExtendedData;

            return(instruction);
        }