aboutsummaryrefslogtreecommitdiff
path: root/examples/brainfuck.false
blob: 0ba9adfd959fb468999ecfe5ee879e0896ec8bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
	to compile:

	(echo "[\"$(head -c30007 /dev/zero)\"]" && cat brainfuck.false) | ../paradox \
		 > brainfuck.asm && nasm -f elf64 brainfuck.asm && ld -o brainfuck brainfuck.o

	REQUIRES PARADOX due to pointer arithmetic.

	stdin is used for both the brainfuck program and its input, separated by a zero byte.
	to read the program from a file and enter input interactively:

	(cat your_program.b && echo -ne '\0' && cat) | ./brainfuck

	example hello world brainfuck program to try:
	echo '+[>>>->-[>->----<<<]>>]>.---.>+..+++.>>.<.>>---.<<<.+++.------.<-.>>+.' | ./brainfuck
}
12+;$$t:h:l:
0d: { change this to 0d: to disable debugging, 1_d: to enable debugging }
0[^$$1_=~\0=~&][\1+]#% $n:
[
	r:\r;+
	1[$0=~][\
		$2+ø
		$'[=[@r;-@@]?
		$']=[@r;+@@]?
		%r;+
	\]#%
	r;-\
]b:
[$0=~][
	d;[
		"src: "
		n;[$0=~][
			$2ø=$[27,"[31m"]?
			\$2+ø,1-\
			[27,"[0m"]?
		]#%
		"mem: "
		t;h; 1ø1ø>~[\]?% h:
		l;[$h;>~][
			$t;=$[27,"[31m"]?
			\$;255&." "\
			[27,"[0m"]?
			1+
		]#%
		^%
	]?

	$ø
	$'>=[t;1+$l;30000+=[%l;]?t:]?
	$'<=[t;$l;=[%l;30000+]?1-t:]?
	$'+=[t;$;$255~&\1+255&|\:]?
	$'-=[t;$;$255~&\1-255&|\:]?
	$'.=[t;;,]?
	$',=[t;$;255~&^|\:]?
	$'[=[t;;255&0=[1_b;!]?]?
	$']=[t;;255&0=~[1b;!]?]?
	%1-
]#%