name: BrainF author: Alain Brobecker (baah/Arm's Tech) size: 272 bytes needs: An Archimedes ;) descr.: A BrainF*ck interpreter ----------------------------------------------------------------------------- __ __ _____ _ _ _ __ | |__ _ ___ _____|__|_ ___| __|_' '_|_____| |__ | _ | ' __| _ | | ' | _||_ _| ___| _| |_____|__| |___._|__|__|__|__| |_._._|_____|__|__| 2001jan03 BrainF*ck is a programming language designed by Urban Mueller, and those who care about their mental sanity ought to turn off their computer right now! (If you liked my previous CC#2 entry SIC and my CC#1 entry SockZ, your mind is already damaged, continue reading! ;) BrainF*ck an experiment to implement a language machine with a minimalist set of instructions and yet be completely Turing-complete without using self-modifying code. There are 8 instructions summarised below... Cmd C Equivalent Effect ~~~ ~~~~~~~~~~~~ ~~~~~~ + array[p]++; Increase element under pointer - array[p]--; Decrease element under pointer > p++; Increase pointer < p--; Decrease pointer [ while (array[p]) { Start loop, counter under pointer ] } Indicate end of loop . putchar(array[p]); Output ASCII code under pointer , array[p]=getchar(); Read char and stores ASCII under pointer All other characters are ignored. The 65536 array elements and the pointer p are initialised to zero at the beginning. While this seems pretty useless as far as languages go, it can be proven that it can compute every solvable mathematical problem if you ignore the size of the array. You've probably already noticed that this is a not a von Neumann machine: the data and the code are kept seperate, so you don't have to worry about overwriting your program. To use the interpreter, write a program (or get one i made), and under the CLI type "BrainF NameOfProgram". For example "BrainF More.Hello". Ok, time to leave you in the hands of the devil... Program in BrainF*ck if you dare! (Better not! ;) ----------------------------------------------------------------------------- Keith Gaughan (hi!) made a RiscOS version available at: http://members.xoom.com/dlm_design/index.htm Also most of the text in here come from his !help file, and he has created the wonderfull "esoteric languages webring". Thanks Keith! His BrainF*ck version was bigger with 328 bytes (mine could easily be reduced down to 256 bytes, see MkBF260), and anyway i liked the concept so had to make my own! ;) I have printed his version and saw their are quite unalike. Technically i'm quite proud of the way i handle the while(){} (ie []). Files included in this archive are: BrainF ;The interpreter ReadMe ;This file More.MkBrainF ;Sourcecode More.MkBF260 ; " for a 260 bytes version, but with too many limitations More.Hello ;A masterpiece More.Add ;Add 32 to 32 and print CHR$(33+33)=B More.Mul10 ;Mul 7 by 10 and print CHR$(7*10)=F More.ReadPrint ;Very simple More.Test ;Print ! More.Lib ;A library of BrainF*ck functions, not yet finished