I\'m trying to write a program with BrainFuck that can read two numbers up to 9, calculate the sum of them and then print the result out, e.g. 3 & 5 give the result 8 .
That is what I know
, ;read character and store it in p1
------------------------------------------------ ;return ascii to Dec
< ;move pointer to p2 (second byte)
, ;read character and store it in p2
------------------------------------------------ ;return ascii to Dec
[ ; enter loop
- ; decrement p2
> ; move to p1
+ ; increment p1
< ; move to p2
] ; we exit the loop when the last cell is empty
> ;go back to p1
++++++++++++++++++++++++++++++++++++++++++++++++ ;return Dec to ascii
. ;print p1
input:
12
output:
3
You should use numbers under 10 and that result under 10