Ejemplo n.º 1
0
        public TestGen(Def def)
        {
            Def = def;
            var fields =
                new LinkedList <(string Name, int Bits, int Shift)>(def.Fields.Select(x =>
                                                                                      (Name: x.Key, x.Value.Bits, x.Value.Shift)));

            IEnumerable <uint> Sub(LinkedList <(string Name, int Bits, int Shift)> parse)
            {
                if (parse.Count == 0)
                {
                    yield break;
                }
                var(name, bits, shift) = parse.First.Value;
                parse.RemoveFirst();
                var values = new List <uint> {
                    0, 1
                };

                if (bits == 5 && name[0] == 'r')
                {
                    values.Add(2);
                    values.Add(3);
                    values.Add(0b11111);
                }
                else if (bits <= 4)
                {
                    values = Enumerable.Range(0, 1 << bits).Select(x => (uint)x).ToList();
                }
                else
                {
                    var max = (1U << bits) - 1;
                    values.Add(max);
                    values.Add(max - 1);
                }

                if (parse.Count == 0)
                {
                    foreach (var value in values)
                    {
                        yield return(value << shift);
                    }
                }
                else
                {
                    var next = Sub(parse).ToList();
                    foreach (var value in values)
                    {
                        foreach (var nv in next)
                        {
                            yield return((value << shift) | nv);
                        }
                    }
                }
            }

            foreach (var values in Sub(fields))
            {
                var inst = def.Match | values;

                var disasm = Disassemble(def, inst);
                if (disasm == null)
                {
                    continue;
                }

                Instructions[inst] = disasm;
            }
            Console.WriteLine($"{def.Name} -- {Instructions.Count} instructions");
        }
Ejemplo n.º 2
0
 Instructions.AsParallel().Select(x => (x.Key, x.Value, CreateConditions(Def, x.Key)))
Ejemplo n.º 3
0
 var cond = CreateConditions(Def, x.Key);