Exemple #1
0
 public void Add(Assembler assembler)
 {
     assemblers.Add(assembler);
     assembler.AssemblerGroup = this;
 }
Exemple #2
0
 public void Remove(Assembler assembler)
 {
     assemblers.Remove(assembler);
     assembler.AssemblerGroup = new AssemblerGroup();
 }
Exemple #3
0
        /// <summary>
        /// called on second pass once labels have already been initialized
        /// addressing method has already been assigned to
        /// </summary>
        /// <param name="assembler"></param>
        public void ResolveLabelsAndAssembleSecondPass(Assembler assembler, int lineno)
        {
            if (this.VariableAssignment != null)
            {
                return;
            }

            if (this.AddressingMethod != null && this.AddressingMethod.Value == Assembly.AddressingMethod.implied)
            {
                //no work to do
                finishResolveLabelsAndAssembleSecondPass();
                return;
            }


            if (!resolveLabels(assembler.Labels) && assembler.AssemblerGroup != null)
            {
                resolveLabels(assembler.AssemblerGroup.Labels);
            }

            if (this.Directive != null)
            {
                this.ComputedBytes = new List <byte>();

                this.Directive.ParseValue();
                if (this.Directive.Bytes != null)
                {
                    this.ComputedBytes = this.Directive.Bytes.ToList();
                    return;
                }

                int n = this.Directive.ComputedValue.GetNumeral();
                switch (this.Directive.Type)
                {
                case DirectiveType.@byte:

                    if (n < 0)
                    {
                        n = Assembly.TwosComplement8bit(n);
                    }

                    if (n < byte.MinValue || n > byte.MaxValue)
                    {
                        throw new SyntaxErrorException("Value out of range for byte");
                    }

                    ComputedBytes.Add((byte)n);
                    return;

                case DirectiveType.word:
                    if (n < 0 || n > ushort.MaxValue)
                    {
                        throw new SyntaxErrorException("Value out of range for word");
                    }

                    foreach (byte b in Assembly.UshortToLE((ushort)n))
                    {
                        ComputedBytes.Add(b);
                    }
                    return;
                }
                throw new SyntaxErrorException("Unspecified error with directive");
            }

            if (this.RValue != null)
            {
                this.RValue.ParseValue(this.OpCode.Value, this.AddressingMethod.Value, PC);
            }

            //Label searching and value setting done - now only concerned with determining the addressing method

            if (this.AddressingMethod != null)
            {
                //The label replacement has been finished by now, and jmps and branches are finished
                finishResolveLabelsAndAssembleSecondPass();
                return;
            }

            //throw new SyntaxErrorException(lineno, "End of second pass reached without finding an addressing method");
        }