tpthlalsc

  • mark2222
    13th Jul 2011 Member 0 Permalink


    Here are the instructions for programming my computer. The default program is GUESS YOU!, instructions below.

    Not all its functionality has been black-box tested yet. If there are any bugs, please tell me.

    Array reading is a simple extension to the computer. However, I would only think about implementing it if there is any more use to such a function other than array reversing or sorting. If anyone would like to do it himself, go ahead.

    Would have loved to implement functions, but would need more space for a 5-bit system in order to do so. (Line numbers are 5-bit, for functions simply need to be able to store are retrieve line numbers in RAM.)

    Do note that it takes about 15 seconds per command, and it can take a really long time for complicated programs. The default program needs to process 15 divided by 2, a very CPU-intensive function, thus you will need to wait for some time before it makes its first guess.

    Command Format:

    [COMMAND - 4 bits][NUM1 - 5 bits][NUM2 - 5 bits]

    NUM1/NUM2:
    If Command is GOTOIF, NUM2 = [Line Number - 5 bits]
    Default: (Note: still applies if command is ASSIGN)
    NUM1/NUM2 = [BOOL FromRAM - 1 bit][NUM - 4 bits]
    If FromRAM is 1 - Read from RAM at address NUM
    If FromRAM is 0 - Constant NUM

    MEMORY:
    0000 - 1100: Normal RAM
    1101: STDIO
    1110: READ ONLY RANDOM
    1111: READ ONLY Operation Result (Result of operation commands)

    BOOLEANS: 1111 = true, 0000 = false

    COMMAND:
    0000: ASG (X = Y)
    0001: ADD (X + Y)
    0010: SUB (X - Y)
    0011: EQL (X == Y)
    0100: LTN (X < Y)
    0101: MOE (X >= Y)
    0110: AND (X & Y)
    0111: ORR (X | Y)
    1000: NND (!X & Y)
    1001: IGT (IF X GOTO Y)
    1111: END (END)

    Below are a few codes you can try. The assembly code is always shown before the machine code.

    The C# code for the more complicated ones are provided.

    I CAN ADD! aka Addition, mod 16:

    STDIN + STDIN
    STDOUT = Operation Result
    END

    Binary:
    0001 11101 11101
    0000 01101 11111
    1111 00000 00000

    MULTIPLICATION IS NO CHALLENGE! aka Multiplication, mod 16:

    0: RAM 0 = STDIN
    1: RAM 1 = STDIN
    2: RAM 2 = 0
    3: RAM 1 == 0
    4: IF Operation Result GOTO 10
    5: RAM 0 + RAM 2
    6: RAM 2 = Operation Result
    7: RAM 1 - 1
    8: RAM 1 = Operation Result
    9: IF TRUE GOTO 3
    10: STDOUT = RAM 2
    11: END

    Binary:
    0000 00000 11101
    0000 00001 11101
    0000 00010 00000
    0011 10001 00000
    1001 11111 01010
    0001 10000 10010
    0000 00010 11111
    0010 10001 00001
    0000 00001 11111
    1001 01111 00011
    0000 01101 10010
    1111 00000 00000

    GUESS ME! aka The More Or Less Game:

    0: RAM 0 = RAN
    1: RAM 1 = STDIN
    2: RAM 1 < RAM 0
    3: IF Operation Result GOTO 8
    4: RAM 0 < RAM 1
    5: IF Operation Result GOTO 10
    6: STDOUT = 15
    7: END
    8: STDOUT = 0
    9: IF TRUE GOTO 1
    10: STDOUT = 1
    11: IF TRUE GOTO 1

    Output Reading: 1 -> Too high, 0 -> Too low, 15 -> Correct

    For a more detailed explanation, see next program, where the computer is the player and you are the host. For this program, you are the player and the computer is the host.

    Binary:
    0000 00000 11110
    0000 00001 11101
    0100 10001 10000
    1001 11111 01000
    0100 10000 10001
    1001 11111 01010
    0000 01101 01111
    1111 00000 00000
    0000 01101 00000
    1001 01111 00001
    0000 01101 00001
    1001 01111 00001

    GUESS YOU! aka The More Or Less Game, where the player is the computer:

    int UpperBound=0,LowerBound=15;
    while(true){
    int Guess=LowerBound+Math.Floor((UpperBound-LowerBound)/2);
    Console.WriteLine(Guess);
    int Result=Console.ReadLine();
    if(Result==0){
    LowerBound=Guess+1;
    }
    if(Result==1){
    UpperBound=Guess-1;
    }
    if(Result==15){
    break;
    }
    }
    END;

    0: RAM 0 = 0
    1: RAM 1 = 15
    2: RAM 1 - RAM 0
    3: RAM 2 = Operation Result
    4: RAM 3 = 0
    5: RAM 2 < 2
    6: IF Operation Result GOTO 12
    7: RAM 3 + 1
    8: RAM 3 = Operation Result
    9: RAM 2 - 2
    10: RAM 2 = Operation Result
    12: RAM 3 + RAM 0
    13: RAM 4 = Operation Result
    14: STDOUT = RAM 4
    15: RAM 5 = STDIN
    16: RAM 5 == 0
    17: IF Operation Result GOTO 21
    18: RAM 5 == 1
    19: IF Operation Result GOTO 24
    20: END
    21: RAM 4 + 1
    22: RAM 0 = Operation Result
    23: IF TRUE GOTO 2
    24: RAM 4 - 1
    25: RAM 1 = Operation Result
    26: IF TRUE GOTO 2

    Input: 1 -> Too high, 0 -> Too low, 15 -> Correct

    Detailed explanation:
    1: Think of a number.
    2: Wait for the computer to guess.
    3: If the guess is more than your number, click 1.
    4: If the guess is less than your number, click 0.
    5: If the guess is your number, click 15.
    6: Then, wait for the computer to shut itself down if you want to play again.

    Binary:
    0000 00000 00000
    0000 00001 01111
    0010 10001 10000
    0000 00010 11111
    0000 00011 00000
    0100 10010 00010
    1001 11111 01100
    0001 10011 00001
    0000 00011 11111
    0010 10010 00010
    0000 00010 11111
    1001 01111 00101
    0001 10011 10000
    0000 00100 11111
    0000 01101 10100
    0000 00101 11101
    0011 10101 00000
    1001 11111 10101
    0011 10101 00001
    1001 11111 11000
    1111 00000 00000
    0001 10100 00001
    0000 00000 11111
    1001 01111 00010
    0010 10100 00001
    0000 00001 11111
    1001 01111 00010

    DIVISION - THE (UN)PRO WAY aka Division, mod 16:

    0: RAM 0 = STDIN
    1: RAM 1 = STDIN
    2: RAM 2 = 0
    3: RAM 0 < RAM 1
    4: IF Operation Result GOTO 10
    5: RAM 0 - RAM 1
    6: RAM 0 = Operation Result
    7: RAM 2 + 1
    8: RAM 2 = Operation Result
    9: IF TRUE GOTO 3
    10: STDOUT = RAM 2
    11: END

    0000 00000 11101
    0000 00001 11101
    0000 00010 00000
    0100 10000 10001
    1001 11111 01010
    0010 10000 10001
    0000 00000 11111
    0001 10010 00001
    0000 00010 11111
    1001 01111 00011
    0000 01101 10010
    1111 00000 00000

    NOTE: Everything below have not been tested yet, and there may be bugs. For some you will have to convert it into binary yourself. If you do convert it yourself, however, it would be greatly appreciated if you could share it.

    THE ROOT OF COMPUTING aka Square Root, floored:

    0: RAM 0 = STDIN
    1: RAM 1 = 0
    2: RAM 2 = RAM 1
    3: RAM 3 = RAM 1
    4: RAM 3 == 0
    5: IF Operation Result GOTO 11
    6: RAM 2 + RAM 1
    7: RAM 2 = Operation Result
    8: RAM 3 - 1
    9: RAM 3 = Operation Result
    10: IF TRUE GOTO 3
    11: RAM 2 >= RAM 0
    12: IF TRUE GOTO 16
    13: RAM 1 + 1
    14: RAM 1 = Operation Result
    15: IF TRUE GOTO 2
    16: STDOUT = RAM 1
    17: END

    Note: There IS a cheat way, with a few if-else blocks. But that isn't the spirit of computing.

    WOW. EXPONENTS. aka Exponents, mod 16:

    int x=Console.ReadLine(),y=Console.ReadLine(),Result=1;
    while(y!=0){
    int MultiplicationResult=0;
    for(int i2=0;i2 MultiplicationResult+=Result;
    }
    Result=MultiplicationResult;
    y--;
    }
    Console.WriteLine(Result);
    END;

    0: RAM 0 = STDIN
    1: RAM 1 = STDIN
    2: RAM 2 = 1
    3: RAM 1 == 0
    4: IF Operation Result GOTO 18
    5: RAM 3 = 0
    6: RAM 4 = 0
    7: RAM 4 == RAM 0
    8: IF Operation Result GOTO 14
    9: RAM 3 + RAM 2
    10: RAM 3 = Operation Result
    11: RAM 4 + 1
    12: RAM 4 = Operation Result
    13: IF TRUE GOTO 7
    14: RAM 2 = RAM 3
    15: RAM 1 - 1
    16: RAM 1 = Operation Result
    17: IF TRUE GOTO 3
    18: STDOUT = RAM 2
    19: END

    Last but not least...

    THE PRIME OF THE SHOW aka Primes, less than 16:

    int Count=0,Attempt=2,Input=Console.ReadLine();
    while(true){
    bool IsPrime=true;
    for(int i=2;i int DivisionWorking=0;
    while(DivisionWorking DivisionWorking+=i;
    }
    if(Attempt==DivisionWorking){
    IsPrime=false;
    break;
    }
    }
    if(IsPrime){
    Count++;
    if(Count==Input){
    Console.WriteLine(Attempt);
    END;
    }
    }
    Attempt++;
    }

    0: RAM 0 = STDIN
    1: RAM 1 = 0
    2: RAM 2 = 2
    3: RAM 4 = 2
    4: RAM 4 >= RAM 2
    5: IF Operation Result GOTO 17
    6: RAM 5 = 0
    7: RAM 5 >= RAM 2
    8: IF Operation Result GOTO 12
    9: RAM 5 + RAM 4
    10: RAM 5 = Operation Result
    11: IF TRUE GOTO 7
    12: RAM 5 == RAM 2
    13: IF Operation Result GOTO 21
    14: RAM 4 + 1
    15: RAM 4 = Operation Result
    16: IF TRUE GOTO 4
    17: RAM 1 + 1
    18: RAM 1 = Operation Result
    19: RAM 1 == RAM 0
    20: IF Operation Result GOTO 24
    21: RAM 2 + 1
    22: RAM 2 = Operation Result
    23: IF TRUE GOTO 3
    24: STDOUT = RAM 2
    25: END

    Any programs you have created yourself for this computer? Share with us!

    How to create a program:

    1. Know how to program it in a high level language like C++.
    2. Write out the assembly code with line numbers (for easy goto reference) in a text file, using only given commands.
    3. Write out the binary form of the assembly code.
    4. Copy it into the programming palette by sparking the PSCN and NSCN. It is easier to zoom to 4/5 switches at a time, and writing it downwards. That is, write all the commands first, then write all the NUM1s, then all the NUM2s.

    A final note to the only type of people who would bother to read all the way down here: if you want to contribute any more functional, faster or smaller components, feel free to. Any style of input can be used, even timed inputs. I value functionality over speed and size, that is, even if it is slower or bigger, I would value it if it has more functionality, but if it is too big I would not be able to fit it in at all. Also, no wifi. It's not that I don't support wifi, it's just that it has limited channels and it gets extremely tedious to heat them at higher channels.
    Edited by mark2222, 2011-07-14 02:15:26
  • The-Con
    13th Jul 2011 Member 0 Permalink
    @mark2222 (View Post)
    Great save, but Unspecific Thread Title.
    I like it... It is very complicated.
    (your description states that it is a "super" computer... it has not got two CPU's or more.)
    Now I have something to strive to match, or even make a better one... one day.
    Edited by The-Con, 2011-07-11 11:41:47
  • mark2222
    13th Jul 2011 Member 0 Permalink
    @The-Con (View Post)
    That's why there are double inverted commas around "super". Thought it would probably be super by powder toy standards...
  • The-Con
    13th Jul 2011 Member 0 Permalink
    @mark2222 (View Post)
    Yes, by PT standards.
    This is much more advanced then anything I have ever published/ saved.
  • TheTempest
    13th Jul 2011 Member 0 Permalink
    If this isn't Front Page today, then the entire FP system needs to be redone. This sir, is epic on all levels.
  • code1949
    13th Jul 2011 Member 0 Permalink
    I wounder how much processing power it would have if it did use wifi...
  • The-Con
    13th Jul 2011 Member 0 Permalink
    @mark2222 (View Post)
    How long did you spend making this?
  • mark2222
    13th Jul 2011 Member 0 Permalink
    @The-Con (View Post)
    Er... I did it over a few weeks, but if you consider 2 other drafts, then it would have spanned months.
  • The-Con
    13th Jul 2011 Member 0 Permalink
    @mark2222 (View Post)
    I see. Electronics take a very long time... In fact I am, and have been in the process of making a processor for a while... but exams leave little time to use TPT.
  • danieagle7
    13th Jul 2011 Member 0 Permalink
    I dont know too elecronic in TPT but... THIS IS AWSOMEE!!!!!
Locked by Lockheedmartin: Necro