Beispiel #1
0
        static void Main(string[] args)
        {
            String inputFileName  = "fib.bin";
            String outputFileName = "boopout.txt";

            byte[] fileBytes = File.ReadAllBytes(inputFileName);

            StringBuilder sb    = new StringBuilder();
            int           count = 0;

            for (int i = 0; i < fileBytes.Length; i += 4)
            {
                count++;
                sb.Insert(0, "\", ");
                sb.Insert(0, AtlasCPU.IntFromBytes(fileBytes[i + 3], fileBytes[i + 2], fileBytes[i + 1], fileBytes[i + 0]).ToString("X8"));
                sb.Insert(0, "X\"");
            }
            while (count++ < 256)
            {
                sb.Insert(0, "\", ");
                sb.Insert(0, "00000000");
                sb.Insert(0, "X\"");
            }
            File.WriteAllText(outputFileName, sb.ToString());
        }
Beispiel #2
0
        //utility functions for working with literals
        private int GetLiteralValue(AtlasParser.LiteralContext literal)
        {
            int val = 0;

            var bytes = BigInteger.Parse(literal.INT().GetText()).ToByteArray();

            val = AtlasCPU.IntFromBytes(bytes.ElementAtOrDefault(3), bytes.ElementAtOrDefault(2), bytes.ElementAtOrDefault(1), bytes.ElementAtOrDefault(0));

            return(val);
        }
Beispiel #3
0
 //utility functions for working with array initilizations
 private int GetArrayInitilizationElementCount(AtlasParser.ArrayInitilizerContext context)
 {
     if (context.OSQUAREBRACE() != null)
     {
         var bytes = BigInteger.Parse(context.INT().GetText()).ToByteArray();
         return(AtlasCPU.IntFromBytes(bytes.ElementAtOrDefault(3), bytes.ElementAtOrDefault(2), bytes.ElementAtOrDefault(1), bytes.ElementAtOrDefault(0)));
     }
     else
     {
         return(context.literal().Count);
     }
 }