Fuck4
Jump to navigation
Jump to search
Fuck4 is four command esoteric language. Fuck4 machine by default has 8 half-bytes 0-127, but this is not strict. In any case memory is finite and looped, this why only one-way pointer shift is required.
Commands
Fuck4 has four commands: f,u,c,k.
- f : increases current byte (brainfuck equivalent: +)
- u : starts loop if current byte not null (brainfuck equivalent: [)
- c : increases pointer position (brainfuck equivalent: >)
- k : ends loop if current byte is null (brainfuck equivalent: ])
+,[,>,] operators can be used instead of f,u,c,k
Stdin/out:
- input: after leaving second memory cell which is set to 2, first memory cell receives input
- output: after leaving second memory cell which is set to 1, first memory cell is printed out
Second cell automatically clears on each pass.
Hello, world!
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcfccccc ccfffffffffffffffffffffffffffffcfcccccccfffffffcfccccccccfcccccccfffcfcccccccuf kffffffffffffffffffffffffffffffffffffffffffffcfcccccccufkffffffffffffffffffffff ffffffffffcfcccccccffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffcfcccccccufkffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcfcccccc cfffcfcccccccufkfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffffffffffffffffffffcfcccccccufkffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc fcccccccufkfffffffffffffffffffffffffffffffffcfc
Fuck4 to C translator on Python:
# http://bfe.host.org/fuck4.html # fuck4 to C translator code in Python from sys import argv if argv.__len__()==1: print("usage: "+argv[0]+" input.fuck [out.c] [memsize] [bytecap]") print("default memsize is 8, default bytecap is 127") else: input = argv[1] output = input+".c" MEMSIZE = 8 BYTECAP = 127 if argv.__len__()==3: output = argv[2] if argv.__len__()==4: MEMSIZE = int(argv[3]) if argv.__len__()==5: BYTECAP = int(argv[4]) r = open(input,'r') w = open(output,'w') if BYTECAP>255: BYTECAP=255 if BYTECAP<1: BYTECAP=1 if MEMSIZE<8: MEMSIZE=8 w.write(" unsigned int p = 0, memsize = "+str(MEMSIZE)+"; char mem["+str(MEMSIZE)+"]; int main() { \n"); code = r.read() r.close() p = 0 sbv = 0 for x in code: if x=="f" or x=="+": w.write(" if (mem[p] == "+str(BYTECAP)+") { mem[p] = 0; } else { ++mem[p]; } \n") if p==1: if sbv==BYTECAP: sbv=0 else: sbv+=1 if x=="u" or x=="[": w.write(" while(mem[p]) { \n"); if x=="c" or x==">": if p==MEMSIZE-1: p=0 else: p+=1 if p==2 and sbv==1: w.write(" if (mem[1]==1) putchar(mem[0]); mem[1]=0; \n") sbv=0 if p==2 and sbv==2: w.write(" if (mem[1]==2) mem[0] = getchar(); mem[1]=0; \n") sbv=0 w.write(" if (p == "+str(MEMSIZE)+"-1) { p = 0; } else { p++; } \n") if x=="k" or x=="]": w.write(" } \n") w.write(" } //\n\n") w.close()