Пример #1
0
 public T this[IndexingRegister reg] {
     get {
         var copy = new T();
         copy.Copy(Vars[0]);
         copy.Name  = Name;
         copy.Index = reg;
         return(copy);
     }
 }
Пример #2
0
        private StructType _makeCopy(StructType original, IndexingRegister index)
        {
            var newInstance = ((StructType?)Activator.CreateInstance(_baseInstance.GetType()))?.Copy(original);

            foreach (var p in newInstance.GetType().GetProperties().Where(x => typeof(Var).IsAssignableFrom(x.PropertyType)).ToList())             //user-defined Var properties
            {
                ((Var)p.GetGetMethod().Invoke(newInstance, null)).Index = index;
            }
            return(newInstance);
        }
Пример #3
0
        public static VByte Ref(Address addr, IndexingRegister index, string name)
        {
            var v = new VByte {
                Address = new Address[] { addr },
                Index   = index,
                Name    = string.IsNullOrEmpty(name) ? addr.ToString() : name
            };

            return(v);
        }
Пример #4
0
            //TODO: for each method, test if loop executed already, exception of true

            public LoopBlock Ascend(IndexingRegister reg)
            {
                if (reg != null)
                {
                    throw new Exception("Loop index already set");
                }
                Reg       = reg;
                Ascending = true;
                return(this);
            }
Пример #5
0
        public static void AscendWhile(IndexingRegister reg, Func <Condition> condition, Action <LoopLabels> block)
        {
            var labels = new LoopLabels();

            Do_old(_ => {
                var before = reg.State.Hash;
                block.Invoke(labels);
                reg.State.Verify(before);
                Context.Write(labels.ContinueLabel);
                reg.Inc();
            }).While(condition);
            Context.Write(labels.BreakLabel);
        }
Пример #6
0
        public static void Descend_Pre(IndexingRegister reg, Action <LoopLabels> block)
        {
            var labels = new LoopLabels();

            Do_old(_ => {
                Context.Write(labels.ContinueLabel);
                reg.Dec();
                var before = reg.State.Hash;
                block.Invoke(labels);
                reg.State.Verify(before);
            }).While(() => reg is RegisterX ? X.NotEquals(0) : Y.NotEquals(0));
            Context.Write(labels.BreakLabel);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="start">Inclusive</param>
        /// <param name="length">Exclusive</param>
        /// <param name="block"></param>
        public static void Repeat(IndexingRegister reg, int length, Action <LoopLabels> block)
        {
            var labels = new LoopLabels();
            //X.Reset();
            var lblStart = Labels.New();

            Context.Write(lblStart);
            Context.New(() => {
                var before = reg.State.Hash;
                block.Invoke(labels);
                reg.State.Verify(before);
                Context.Write(labels.ContinueLabel);
                reg.Inc();
                if (Context.StartBranchable)
                {
                    if (length < 256)
                    {
                        if (reg is RegisterX)
                        {
                            CPU6502.CPX((U8)length);
                        }
                        else
                        {
                            CPU6502.CPY((U8)length);
                        }
                    }
                    CPU6502.BNE(Context.Start);
                }
                else
                {
                    //TODO: verify this works!
                    if (length < 256)
                    {
                        if (reg is RegisterX)
                        {
                            CPU6502.CPX((U8)length);
                        }
                        else
                        {
                            CPU6502.CPY((U8)length);
                        }
                    }
                    CPU6502.BEQ(3);
                    GoTo(lblStart);
                }
            });
            Context.Write(labels.BreakLabel);
        }
Пример #8
0
 public VByte Set(IndexingRegister reg)
 {
     if (Index != null && Index == reg)
     {
         throw new NotImplementedException();
     }
     if (reg is RegisterX)
     {
         CPU6502.STX(this);
     }
     else
     {
         CPU6502.STY(this);
     }
     return(this);
 }
Пример #9
0
 public static void ForEach <T>(IndexingRegister index, StructOfArrays <T> items, Action <T, LoopLabels> block) where T : Struct, new()
 {
     if (index is RegisterX)
     {
         AscendWhile(X.Set(0), () => X.NotEquals(items.Length == 256 ? 0 : items.Length), lblsX => {
             var before = X.State.Hash;
             block?.Invoke(items[X], lblsX);
             X.State.Verify(before);
         });
     }
     else
     {
         AscendWhile(Y.Set(0), () => Y.NotEquals(items.Length == 256 ? 0 : items.Length), lblsY => {
             var before = Y.State.Hash;
             block?.Invoke(items[Y], lblsY);
             Y.State.Verify(before);
         });
     }
 }
Пример #10
0
 public LabelIndexed(Label label, IndexingRegister reg)
 {
     Label = label;
     ((IIndexable)this).Index = reg;
 }
Пример #11
0
 public LabelIndexed this[IndexingRegister reg] => new LabelIndexed(this, reg);
Пример #12
0
 public StructType this[IndexingRegister reg] => _makeCopy(_structs[0], reg);
Пример #13
0
 public VByte this[IndexingRegister r] => Ref(Address[0], r, Name);
Пример #14
0
 public static LoopBlock Descend(IndexingRegister reg) => new LoopBlock().Descend(reg);
Пример #15
0
 //TODO: figure out how to handle indexing reg's. They should never get into GenericAssembler, but they should also act as operands for higher level stuff.
 //Vars shouldn't have to specify a second Set function just for specifying IndexingRegister params.
 public RegisterA Set(IndexingRegister u8) => Set((IOperand)u8);
Пример #16
0
 public AddressIndexed this[IndexingRegister r] => new AddressIndexed(this, r);
Пример #17
0
 //public IndexingRegister? Index = null;
 public AddressIndexed(ushort value, IndexingRegister reg) : base(value) => Index = reg;
Пример #18
0
 public StructType this[IndexingRegister index] => _makeCopy(0, index);