Exemplo n.º 1
0
 private static Instruction Instruction(
     OpCode code,
     AddressingMode mode,
     string addressString    = null,
     string label            = null,
     int lineNumber          = 0,
     LabelFinder labelFinder = null)
 {
     return(new InstructionFactory(labelFinder).Create(code, mode, addressString, lineNumber, label));
 }
Exemplo n.º 2
0
        public void LabelFinder_OnlyFindsTheFirstLabel_IfThereAreTwoLabelsToTheSameLine_HopefullyThisIsntAProblem()
        {
            string pretemplate = @"0: LDC 6, 9(0) ; set registers 6 to value 9
101: LDA 7, [label0](0)  ; jump to label label0

102: LDC 1, 1(0)     ; load constant into r1
103: OUT 1, 0, 0           ; write out contens of r1
* label:label0
* label:label1
104: LDC 1, 2(0)     ; load constant into r1
105: OUT 1, 0, 0           ; write out contens of r1";

            var dictionary = LabelFinder.FindLabels(pretemplate);

            Assert.That(dictionary.Count, Is.EqualTo(1));
            Assert.That(dictionary["label0"], Is.EqualTo("104"));
        }
Exemplo n.º 3
0
        public void LabelFinder_ShouldWorkWithBigLineNumbers()
        {
            string pretemplate = @"0: LDC 6, 9(0) ; set registers 6 to value 9
101: LDA 7, [label0](0)  ; jump to label label0

102: LDC 1, 1(0)     ; load constant into r1
103: OUT 1, 0, 0           ; write out contens of r1
* label:label0

104: LDC 1, 2(0)     ; load constant into r1
105: OUT 1, 0, 0           ; write out contens of r1";

            var dictionary = LabelFinder.FindLabels(pretemplate);

            Assert.That(dictionary.Count, Is.EqualTo(1));
            Assert.That(dictionary["label0"], Is.EqualTo("104"));
        }
Exemplo n.º 4
0
 public InstructionParser(LabelFinder labelFinder)
 {
     _factory = new InstructionFactory(labelFinder);
 }
Exemplo n.º 5
0
 public TwoByteAddressInstruction(LabelFinder labelFinder) : base(labelFinder)
 {
 }
 public SingleByteAddressInstruction(LabelFinder labelFinder) : base(labelFinder)
 {
 }
Exemplo n.º 7
0
 protected Instruction(LabelFinder labelFinder)
 {
     _labelFinder = labelFinder;
 }
Exemplo n.º 8
0
 public InstructionFactory(LabelFinder labelFinder)
 {
     _labelFinder = labelFinder;
 }