Exemplo n.º 1
0
     _mapCollection = new MapCollection()
     {
         RegisterMap         = new Dictionary <Z80Register, WorkspaceRegister>(),
         ExtendedRegisterMap = new Dictionary <Z80ExtendedRegister, WorkspaceRegister>(),
         MemoryMap           = memoryMap
     };
     registerMap.ForEach((sourceReg) =>
     {
         if (sourceReg.Item1 <= Z80SourceRegister.L)
         {
             var key = (Z80Register)Enum.Parse(typeof(Z80Register), Enum.GetName(typeof(Z80SourceRegister), sourceReg.Item1));
             _registerMap.Add(key, sourceReg.Item2);
         }
         else
         {
             var key = (Z80ExtendedRegister)Enum.Parse(typeof(Z80ExtendedRegister), Enum.GetName(typeof(Z80SourceRegister), sourceReg.Item1));
             _extendedRegisterMap.Add(key, sourceReg.Item2);
         }
     });
     LabelHighlighter = labelHighlighter;
 }
Exemplo n.º 2
0
 public NopTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }
 public CallCommandTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }
 public ConditionalReturnCommandTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }
 public TMS9900MultilineTranslator(Z80AssemblyParsing.Parsing.Z80LineParser parser, TMS9900Translator translator)
 {
     _parser           = parser;
     _translator       = translator;
     _labelHighlighter = translator.LabelHighlighter;
 }
Exemplo n.º 6
0
 public UnparsableTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }
 public CommandTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter)
 {
     _mapCollection    = mapCollection;
     _labelHighlighter = labelHighlighter;
 }
 public BlankLineTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }
 public UnconditionalJumpCommandTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }
Exemplo n.º 10
0
        public void MultilineTests_IncrementDecrementLabels()
        {
            var z80code              = @"start: ld b,c
        inc  b
        dec  c
one:
        inc  de
        add  (dec002),(hl)
        inc  de
        dec  de
        dec  de
        call start";
            var z80CodeList          = z80code.Split(Environment.NewLine);
            var labelHighlighter     = new LabelHighlighter();
            var singleLineTranslator = new TMS9900Translator(new List <(Z80SourceRegister, WorkspaceRegister)>()
            {
                (Z80SourceRegister.IX, WorkspaceRegister.R1),
                (Z80SourceRegister.IY, WorkspaceRegister.R2),
                (Z80SourceRegister.SP, WorkspaceRegister.R3),
                (Z80SourceRegister.A, WorkspaceRegister.R4),
                (Z80SourceRegister.B, WorkspaceRegister.R5),
                (Z80SourceRegister.C, WorkspaceRegister.R6),
                (Z80SourceRegister.D, WorkspaceRegister.R7),
                (Z80SourceRegister.E, WorkspaceRegister.R8),
                (Z80SourceRegister.H, WorkspaceRegister.R9),
                (Z80SourceRegister.L, WorkspaceRegister.R9)
            },
                                                             new List <MemoryMapElement>()
            {
            },
                                                             labelHighlighter);
            var translator  = new TMS9900MultilineTranslator(new Z80LineParser(), singleLineTranslator);
            var tmsCodeList = translator.Translate(z80CodeList).Select(c => c.CommandText);
            //Since "one" and "dec002" are labels that were defined by the Z80 code,
            //the translator has to come up with new labels.
            var expected     = @"start  DECT R3
       MOV  R11,*R3
       MOVB R6,R5
       AB   @ONE000,R5
       SB   @ONE000,R6
one
       AB   @ONE000,R8
       JNC  INC001
       AB   @ONE000,R7
       JMP  INC002
INC001 MOVB R7,R7
INC002
       AB   *R9,@dec002
       AB   @ONE000,R8
       JNC  INC003
       AB   @ONE000,R7
       JMP  INC004
INC003 MOVB R7,R7
INC004
       SB   @ONE000,R8
       JNC  DEC001
       SB   @ONE000,R7
       JMP  DEC003
DEC001 MOVB R7,R7
DEC003
       SB   @ONE000,R8
       JNC  DEC004
       SB   @ONE000,R7
       JMP  DEC005
DEC004 MOVB R7,R7
DEC005
       BL   @start";
            var expectedList = expected.Split(Environment.NewLine).ToList();
            var i            = 0;

            foreach (var tmsCodeLine in tmsCodeList)
            {
                Assert.IsTrue(i < expectedList.Count());
                Assert.AreEqual(expectedList[i++].TrimEnd(), tmsCodeLine.TrimEnd());
            }
        }
 public ConditionalAddressChangeCommandTranslator(MapCollection mapCollection, LabelHighlighter labelHighlighter) : base(mapCollection, labelHighlighter)
 {
 }