public override IEnumerable <TmsCommand> Translate(Z80AssemblyParsing.Commands.UnconditionalRelativeJumpCommand callCommand)
        {
            if (callCommand.Operand is Z80AssemblyParsing.Operands.LabeledAddressWithoutParenthesisOperand labelOperand)
            {
                var destinationOperand = new Operands.LabeledAddressWithoutAtTmsOperand(labelOperand.Label);
                yield return(new JumpCommand(callCommand, destinationOperand));
            }
            else
            {
                yield return(new UntranslateableComment(callCommand, "cannot translate a jump command if it is to a literal address"));

                yield return(new UntranslateableComment(callCommand, callCommand.SourceText));
            }
        }
예제 #2
0
        public override IEnumerable <Command> Translate(DjnzCommand djnzCommand)
        {
            if (djnzCommand.Operand is Z80AssemblyParsing.Operands.LabeledAddressWithoutParenthesisOperand labeledZ80Operand)
            {
                var destinationOperand = new Operands.LabeledAddressWithoutAtTmsOperand(labeledZ80Operand.Label);
                //Decrement Register B
                foreach (var command in base.Translate(new DjnzCommand(djnzCommand.SourceText, new Z80AssemblyParsing.Operands.RegisterOperand(Z80AssemblyParsing.Register.B))))
                {
                    yield return(command);
                }
                //Jump if register B is not equal to zero
                yield return(new JumpIfNotEqualCommand(djnzCommand, destinationOperand));
            }
            else
            {
                yield return(new UntranslateableComment(djnzCommand, "can only translate a DJNZ command if it is to a labeled address"));

                yield return(new UntranslateableComment(djnzCommand, djnzCommand.SourceText));
            }
        }
        public override IEnumerable <TmsCommand> Translate(Z80AssemblyParsing.Commands.ConditionalRelativeJumpCommand jumpCommand)
        {
            Operand destinationOperand = null;

            if (jumpCommand.AddressOperand is Z80AssemblyParsing.Operands.LabeledAddressWithoutParenthesisOperand labelOperand)
            {
                destinationOperand = new Operands.LabeledAddressWithoutAtTmsOperand(labelOperand.Label);
            }

            if (destinationOperand == null)
            {
                yield return(new UntranslateableComment(jumpCommand, "cannot translate a jump command if it is to a literal address"));

                yield return(new UntranslateableComment(jumpCommand, jumpCommand.SourceText));
            }
            else if (_typesByCondition.ContainsKey(jumpCommand.ConditionOperand.Condition))
            {
                var translatorType = _typesByCondition[jumpCommand.ConditionOperand.Condition];
                yield return((CommandWithOneOperand)Activator.CreateInstance(translatorType, new object[] { jumpCommand, destinationOperand }));
            }
        }