It's been a while since I've posted anything. I know most of you are all playing latest builds of FTB, but since I'm stuck to a really old laptop that can barely handle Monster, I'm gonna have to bring you all down a few notches back to the days of 1.4.7. You got it, this map was designed in FTB Ultimate, and it is nearly 100% Redpower, with a bit of wireless redstone mixed in for convenience.
This is not a typical computer build. its built around a language some of you may have heard of called BrainF*ck. Its a language that has only 8 instructions:
+ : increment current cell ( mem[p]++ )
- : decrement current cell ( mem[p]-- )
> : move to next cell ( p++ )
< : move to previous cell ( p-- )
[ : if current cell is 0, jump to matching ] instruction, otherwise continue ( while (mem[p] != 0) )
] : if current cell is not 0, jump to matching [ instruction, otherwise continue ( end while )
. : output current cell value as ascii character ( putchar(mem[p]) )
, : input a character into current cell ( mem[p] = getchar() )
There are quite a few pages, references, wiki guides, code and interpreters written in many languages out on the web that can load and run a BF program. Keep in mind this is not a serious programming language, its very difficult to do anything useful (the biggest bf program i know of is a BF interpreter...written in BF itself, and a mandelbrot generator).
Typically, a BF environment provides about 30k of memory, usually unsigned bytes, and most agree on a few things like when the program should stop, how it behaves in certain conditions, etc. This map is a very
simple implementation of a BF 'computer' that can actually execute a valid BF program. The only thing it cant do is the input instruction, but im sure a little craftiness with a cc turtle can provide something useful. Maybe sometime I'll do it, but this is a very rough start
so on to the images:
this shows the entire map. flowing down from the middle to bottom left is the memory, 16 bytes of it. in
front of that is a single 8 bit register used as the 'p' variable in the pseudo code above, it handles selecting which byte is being written to/read from. next to the memory is the instruction circuits and motor control
circuits that drive a platform that reads the code set on that long strip you see on the top going to the right
this is the memory, all 16 bytes of it. these are just stacks of redpower multiplexors with adress control/clock logic underneath each stack. Thes address logic under each one uses bus transcievers to select which 8 bit register i want to read/write to, plus a reset line that will zero all the memory in one pulse.
in front of the memory is the 'index' register, this stores the address of the current byte im reading/writing to
attached to the register are 2 sets of adder circuits. one does a +1 operation, the other does a -1. They are all half adder circuits where the first bit is added with a constant 1, the rest are added to the last bit's carry. Theres a control line that will select which of these will be sent to the inputs of the register. The memory also has a pair of circuits exactly like this, also with a control line to select wether to do the +1/-1 operation. The adders take the output bits of the register/memory, and feed the result back into the register/memory input bits. clocking the register or memory will set the result. for the curious, the -1 circuit follows a simple formula: x -1 = not(not(x) + 1). hence all the not gates on the inputs and outputs.
connected to the memory output is a zero value circuit, this is used for the looping instructions. below that you can see the 4-16 decoder circuit, this takes the lowest 4 bits of the index register and enables a select line to the correct memory stack i want to read/write to
Here is where incoming instructions are decoded and sent down the proper path to execute. Executing an opcode is really just toggling 1 or 2 control lines like setting +1/-1 operation, clocking memory, and sending a pulse to the read head platform to read next instruction or start a looping task.
these are the platform control circuits. The platform is driven via wireless redstone. the rightmost circuit is a single step, it moves the platform ahead one tile, then starts the opcode execution. the middle circuit is for while loops, if the loop condition is 0, we need to advance the head up to the end loop instruction, then have it continue on the next instruction. the next circuit is the loop back, it moves the platform back to the top of the while loop. the rightmost circuit resets the platform back to the beginning of the code.
And the best part...this platform is what 'parses' the bf code into opcodes the computer can execute. There are 3 redstone tubes underneath the platform. as it moves over the stone strip, if there is a torch underneath that tube, it will send a signal up to the transmitter up on top of the platform. this lets us write the BF code, literally, onto the stone strip. This is similar to the punch card computers of old times, back before any form of magnetic media was even invented. each opcode is a 3 bit combination represented by the redstone torches. the opcodes are mapped out like this:
001 = +
010 = -
011 = >
100 = <
101 = [
110 = ]
111 = .
where 0 is air, 1 is a torch
on the back of the platform, there is an additional device. this is how i can handle loops. If a start loop instruction is found, a signal is sent to the platform to place a torch on that separate stone track. when an end loop instruction is found, the platform starts backing up. if a torch on that track is detected, it stops the platform. the loop instruction removes the torch, then places it again if the loop condition is true. If it is not true, then the platform is moved ahead until the end loop instruction and resumes normal execution. once an empty instruction is found, the platform stops.
so far, basic things work. There are still a few quirks, one big one being that for some reason, the platform will just...stop. I dont know whats causing it, i dont know if its my timing, a race condition, the frame motors acting stupid, i dont know. im still working on it, but for now, im happy with how it turned out. id love to do this in monster, see this done with project red and use mfr rednet cables to kill some of the lag, but without frames/motors..thats a tough call
This is not a typical computer build. its built around a language some of you may have heard of called BrainF*ck. Its a language that has only 8 instructions:
+ : increment current cell ( mem[p]++ )
- : decrement current cell ( mem[p]-- )
> : move to next cell ( p++ )
< : move to previous cell ( p-- )
[ : if current cell is 0, jump to matching ] instruction, otherwise continue ( while (mem[p] != 0) )
] : if current cell is not 0, jump to matching [ instruction, otherwise continue ( end while )
. : output current cell value as ascii character ( putchar(mem[p]) )
, : input a character into current cell ( mem[p] = getchar() )
There are quite a few pages, references, wiki guides, code and interpreters written in many languages out on the web that can load and run a BF program. Keep in mind this is not a serious programming language, its very difficult to do anything useful (the biggest bf program i know of is a BF interpreter...written in BF itself, and a mandelbrot generator).
Typically, a BF environment provides about 30k of memory, usually unsigned bytes, and most agree on a few things like when the program should stop, how it behaves in certain conditions, etc. This map is a very
simple implementation of a BF 'computer' that can actually execute a valid BF program. The only thing it cant do is the input instruction, but im sure a little craftiness with a cc turtle can provide something useful. Maybe sometime I'll do it, but this is a very rough start
so on to the images:
this shows the entire map. flowing down from the middle to bottom left is the memory, 16 bytes of it. in
front of that is a single 8 bit register used as the 'p' variable in the pseudo code above, it handles selecting which byte is being written to/read from. next to the memory is the instruction circuits and motor control
circuits that drive a platform that reads the code set on that long strip you see on the top going to the right
this is the memory, all 16 bytes of it. these are just stacks of redpower multiplexors with adress control/clock logic underneath each stack. Thes address logic under each one uses bus transcievers to select which 8 bit register i want to read/write to, plus a reset line that will zero all the memory in one pulse.
in front of the memory is the 'index' register, this stores the address of the current byte im reading/writing to
attached to the register are 2 sets of adder circuits. one does a +1 operation, the other does a -1. They are all half adder circuits where the first bit is added with a constant 1, the rest are added to the last bit's carry. Theres a control line that will select which of these will be sent to the inputs of the register. The memory also has a pair of circuits exactly like this, also with a control line to select wether to do the +1/-1 operation. The adders take the output bits of the register/memory, and feed the result back into the register/memory input bits. clocking the register or memory will set the result. for the curious, the -1 circuit follows a simple formula: x -1 = not(not(x) + 1). hence all the not gates on the inputs and outputs.
001 = +
010 = -
011 = >
100 = <
101 = [
110 = ]
111 = .
where 0 is air, 1 is a torch
on the back of the platform, there is an additional device. this is how i can handle loops. If a start loop instruction is found, a signal is sent to the platform to place a torch on that separate stone track. when an end loop instruction is found, the platform starts backing up. if a torch on that track is detected, it stops the platform. the loop instruction removes the torch, then places it again if the loop condition is true. If it is not true, then the platform is moved ahead until the end loop instruction and resumes normal execution. once an empty instruction is found, the platform stops.
so far, basic things work. There are still a few quirks, one big one being that for some reason, the platform will just...stop. I dont know whats causing it, i dont know if its my timing, a race condition, the frame motors acting stupid, i dont know. im still working on it, but for now, im happy with how it turned out. id love to do this in monster, see this done with project red and use mfr rednet cables to kill some of the lag, but without frames/motors..thats a tough call
Last edited: