Esempio n. 1
0
        static void Main(string[] args)
        {
            string bfHelloWorld = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
            string bfSimpleAdd  = @"
            ++          Cell c0 = 2
            > +++++     Cell c1 = 5

            [           Start your loops with your cell pointer on the loop counter(c1 in our case)
                <+      Add 1 to c0
                >-      Subtract 1 from c1
            ]           End your loops with the cell pointer on the loop counter

            At this point our program has added 5 to 2 leaving 7 in c0 and 0 in c1
            BUT we cannot output this value to the terminal since it's not ASCII encoded!

            To display the ASCII character ""7"" we must add 48 to the value 7!
            48 = 6 * 8 so let's use another loop to help us!

            ++++++++    c1 = 8 and this will be our loop counter again
            [
                <++++++ Add 6 to c0
                >-      Subtract 1 from c1
            ]
            <.          Print out c0 which has the value 55 which translates to ""7""!";

            Brainfuck.Run(bfSimpleAdd);
            Console.ReadLine();
        }
Esempio n. 2
0
 public BrainfuckException(string message, Brainfuck program, Exception innerException = null)
     : base($"{message} at index {program.instrPtr}", innerException)
 {
     Program          = program;
     Memory           = Program.MemoryAsString();
     InstructionIndex = Program.instrPtr;
     Instruction      = Program.CurrentInstr;
 }