DebateFort - Where Warriors Come To Debate
RAGECRY - Funny, Amusing, Interesting, Trending & Viral Videos and Images
GameOrc - Free Flash Games Online
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 19
  1. #1
    Leecher sockopen's Avatar
    Join Date
    Jan 2006
    Posts
    14
    Reputation
    10
    Thanks
    0

    brainfuck Programming

    This tutorial is for the programming language Brainfuċk, I used the Brainfuċked compiler, there's also a popular Brainfuċk interpreter in PHP. The Brainfuċked compiler is 799 bytes, has syntax checking, and of course is open source. The smallest compiler in the world is for Brainfuċk, and is 171 bytes.

    Brainfuċk is a cross-platform programming language with only eight instructions, and no operands, no variables, no conditions, and of course no functions.

    Let's go through all of the possible instructions you can use with Brainfuċk:

    > move the memory pointer to the next memory block
    < move the memory pointer to the previous memory block
    + increases the memory cell under the memory pointer
    - decreases the memory cell under the memory pointer
    [ starts a 'while' loop "c while(cur_block_value != 0)"
    ] ends a 'while' loop
    . writes the contents of the memory cell under the memory pointer as an ASCII character "c putchar()"
    , reads an ASCII character input and fills the memory cell under the memory pointer "c getchar()"

    Anything that's not one of those eight characters will be ignored by the compiler and taken as comments. The memory pointer always starts on the left-most memory block, and all memory blocks start with a zero value.



    Now let's do some coding, open up Notepad, and remember to save your projects as *.b's.

    First Program
    Code:
    +++++[-]
    That's the full code for our first program in brainfuċk, normally you start with a Hello World program, but, we'll get there eventually, it's more complex than you would first imagine.

    +++++[-] does several things. First we are increasing the memory cell under the memory pointer to five. Then we enter a loop that loops subtracting our value of five by one until it reaches zero, then exits the loop. This could take up to five lines of code in a language such as C, which is also less efficient.

    Second Program
    Code:
    >>>++
    This moves our memory pointer to the third memory block and increases the memory cell's stored value by two.

    Now let's add onto this program, we'll change several memory cell's values.

    Code:
    >>>++<<+>>+++
    Now this program moves our memory pointer to the third memory block, increases the memory cell's stored value by two, goes back to the first memory block and increases that memory cell's stored value by one. Then goes back to our third memory block and increases our existing memory cell value (of two), to five by incrementing it by three.

    Final Program
    Until now, you haven't been able to see your own programs' calculations. Let's create a program that has some output, the 'Hello World' program.

    Code:
    >+++++++++[<++++++++>-]<.[-]
    >++++++++++[<++++++++++>-]<+.[-]
    >+++++++++++[<++++++++++>-]<--..[-]
    >+++++++++++[<++++++++++>-]<+.[-]
    >+++++++[<++++++>-]<++.[-]
    >++++++[<+++++>-]<++.[-]
    >++++++++++[<+++++++++>-]<---.[-]
    >+++++++++++[<++++++++++>-]<+.[-]
    >+++++++++++[<++++++++++>-]<++++.[-]
    >+++++++++++[<++++++++++>-]<--.[-]
    >++++++++++[<++++++++++>-]<.[-]
    +++++++++++++.---.-
    Since we can only work with numbers, we have to use characters' ASCII values to represent the characters we want to output.

    Program Breakdown:

    Code:
    >+++++++++[<++++++++>-]<.
    First increases the memory pointer to the first memory block, and increases the memory cell's value to nine. We then enter our loop, go back to our zero block and change it's value to eight, go back to our first memory block and decrease the memory cell's stored value to eight, and, returns back to the start of our loop until the memory cell the memory pointer is on is equal to zero. This loop continues until our zero memory block is at 72, and our first memory block is at zero. We then return our memory pointer to the zero memory block, and with our '.', we print the ASCII decimal value, which represents the letter 'H'.

    As you can imagine, it then goes through the rest of the characters and does the same.



    I hope you enjoy programming in Brainfuċk as much as I have. Once you get good with Brainfuċk, I suggest moving to Brainfork and Braintwist, which still use the core idea of Brainfuċk, with extra capabilities.

  2. #2
    Choob RCEisForMe's Avatar
    Join Date
    Feb 2006
    Posts
    39
    Reputation
    9
    Thanks
    0
    Hang on, why would you program in brainfuck when you could program in c, or asm, or if you swing that way another pointless, esoteric language like cow? (http://en.wikipedia.org/wiki/COW_programming_language)

  3. #3
    Threadstarter
    Leecher
    sockopen's Avatar
    Join Date
    Jan 2006
    Posts
    14
    Reputation
    10
    Thanks
    0
    It's a challenge, which aspiring programmer would not like to know an extra language? Especially one so challenging and unique such as brainfuck?

  4. #4
    I AM THE LAW
    Head Administrator
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    22,480
    Reputation
    1725
    Thanks
    30,632
    My Mood
    Devilish
    Can't say I have heard of "BrainFuck"





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOUR ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311HAD VIRTUAL DETOX

  5. #5
    Blackhat Hacker gunot's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    1,873
    Reputation
    29
    Thanks
    225
    looks ugly...

  6. #6
    Choob RCEisForMe's Avatar
    Join Date
    Feb 2006
    Posts
    39
    Reputation
    9
    Thanks
    0
    Like Cow, Brainfuck is pretty much a joke language, like that 1337-speak programming language.

  7. #7
    Newbie pepsi_dude_777's Avatar
    Join Date
    Jan 2006
    Posts
    70
    Reputation
    10
    Thanks
    0
    hmm, brainfuck program, never heard of it either, i think C++ would be easier

  8. #8
    Member shercipher's Avatar
    Join Date
    Dec 2005
    Posts
    108
    Reputation
    10
    Thanks
    10
    The point of brainfuck is to be hard not to be useful.

    There is one called fuckfuck (not related) in which the entire language is composed of curse words.

  9. #9
    Rat King
    Admin
    arunforce's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    Estados Unidos
    Posts
    14,798
    Reputation
    1171
    Thanks
    4,132
    My Mood
    Twisted
    Binary seems hardest, no matter how you look at it.
    Recent Favorites:
    Movies:
    TV Shows:
    Games: BattleTale, Metal Gear Revengence

    What is surprising about humanity: “Man. Because he sacrifices his health in order to make money. Then he sacrifices money to recuperate his health. And then he is so anxious about the future that he does not enjoy the present; the result being that he does not live in the present or the future; he lives as if he is never going to die, and then dies having never really lived.” -- Unknown

    “When I do good, I feel good. When I do bad, I feel bad. That's my religion." -- Abraham Lincoln
    "You can have everything (money, cars, family, career), but it doesn't mean anything if you don't got your health." ~~ GSP



    It takes skill to build an empire. It takes an idiot to maintain it.
    Play some fun Flash games!
    Ready to unlock the hero experience?
    Why am I so mean to you?
    #StankyRich

    This post is protected by Stanky Rich Enterprises Inc., LLC, LC, Ltd. Co., LLP. Any copying will result in decapitation by mouse trap under the maximum extend of the law.


  10. #10
    Member SpiderByte's Avatar
    Join Date
    Jan 2006
    Posts
    103
    Reputation
    10
    Thanks
    3
    Binary is easy as shit

  11. #11
    Choob Firey's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Posts
    44
    Reputation
    28
    Thanks
    19
    if you pass this, you can code binary.

    There a 10 types of people in the world, those who read binary, and those who don't.

  12. #12
    I AM THE LAW
    Head Administrator
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    22,480
    Reputation
    1725
    Thanks
    30,632
    My Mood
    Devilish
    Ugh.... RIGHT... Binary ain't easy as shit wtf. Try writing a whole program in binary...





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOUR ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311HAD VIRTUAL DETOX

  13. #13
    Leecher [gen]'s Avatar
    Join Date
    Jan 2006
    Posts
    11
    Reputation
    10
    Thanks
    0
    noone programs in binary anymore, binary is just how the machine interprets other programming languages..it was the whole reason assembly came to life.

  14. #14
    Leecher
    MPGH Member
    BaGGy's Avatar
    Join Date
    Dec 2005
    Gender
    female
    Posts
    14
    Reputation
    10
    Thanks
    0
    Brainfuck was written just for fun, and is somewhat a language but not a useful one. Or not even a language people will use.

    Also, you really didnt write that tutorial, you took it from an earlier version of the wikipedia page, damn biters...

  15. #15
    Synthetic Hacker Mikoll's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    in the niggaz department
    Posts
    1,351
    Reputation
    11
    Thanks
    28
    it's so fnny how everyone keeps saying it and no one has said anything about the name ahahaha... Brainfuck

Page 1 of 2 1 2 LastLast

Similar Threads

  1. a good java program
    By snipelock in forum Java
    Replies: 18
    Last Post: 04-17-2009, 02:56 PM
  2. Ennyone know of HACKING PROGRAMS
    By daniel1322dan in forum General Hacking
    Replies: 9
    Last Post: 07-24-2008, 06:46 PM
  3. Runescape 2 auto programs
    By fabled in forum Hack Requests
    Replies: 19
    Last Post: 09-05-2007, 01:43 PM
  4. [Tutorial] Your first program
    By akimoko in forum C++/C Programming
    Replies: 10
    Last Post: 06-23-2007, 12:58 PM
  5. Problem Wit Hacking Programs
    By f5awp in forum General Gaming
    Replies: 5
    Last Post: 01-10-2006, 05:44 AM