forked from iamcal/brainfuck-debug
/
index.html
124 lines (121 loc) · 6.75 KB
/
index.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html>
<head>
<title>Javascript Brainfuck Interpreter / Debugger</title>
<meta charset="UTF-8">
<script language="Javascript" src="brainfuck.js">
</script>
<style>
body {
margin: 0px;
background-color: #202020;
color: #fff;
font-family: Arial, Helvetica, Sans-serif;
}
pre.progview {
}
textarea.editsmall {
width: 400px;
height: 100px;
color:#fff;
background-color:#444;
}
textarea.edit {
width: 400px;
height: 200px;
color:#fff;
background-color:#444;
}
div.main {
padding: 6px;
border: 1px solid #000;
background-color: #444;
}
pre.viewer {
width: 500px;
padding: 6px;
border: 1px solid #000;
background-color: #444;
margin: 0px;
overflow: auto;
}
</style>
</head>
<body onload="init();">
<div id="page">
<form id="mainform" name="mainform">
<table align="center" border="0" cellpadding="0" cellspacing="20">
<tr valign="top">
<td colspan="2">
<h1>Javascript Brainfuck Interpreter / Debugger</h1><b>By <a href="http://www.iamcal.com/">Cal Henderson</a></b><br>
Source available on <a href="https://github.com/iamcal/brainfuck-debug">Github</a><br>
<hr>
</td>
</tr>
<tr valign="top">
<td>Program:<br>
<select id="edit_progs" onchange="this.form.source.value=this.options[this.selectedIndex].value; this.selectedIndex=0;">
<option value="">
Example programs...
</option>
<option value="++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.">
Hello World
</option>
<option value="+>+++++)<{)>==+++.=---.$=++..+++.<.)>)>(<_$=+++.>.)+++.(---._---.<<+.">
Hello World (Stacked Brainfuck)
</option>
<option value="++++){)>+++)+{$=>+++){++[<<+.>+.>-]">
Alphabet lower/uppercase (Stacked Brainfuck)
</option>
<option value=",[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>++++++++++++++<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>>+++++[<----->-]<<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>++++++++++++++<-[>+<-[>+<-[>+<-[>+<-[>+<-[>++++++++++++++<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>>+++++[<----->-]<<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>++++++++++++++<-[>+<-]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]>.[-]<,]">
Rot 13 (slow!)
</option>
<option value="+++++++++++>+>>>>++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<+>>[-]]<<<<<<<]>>>>>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++++++++++++++++++++++++++++++++++++++++++++++.[-]<<<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]">
Fibonacci Numbers
</option>
<option value="++++++++++++++++++++#++++++++++++++++++++#++++++++++++++++++++#++++++++++++++++++++#++++++++++++++++++++#-.--.+++++++++++.">
Breakpoints Demo
</option>
</select><br>
<textarea class="edit" id="edit_source" name="source" wrap="virtual"></textarea><br>
<br>
Input:<br>
<input id="input_mode_1" name="input_mode" onclick="sync_input();" type="radio" value="1"> Prompt for input as needed<br>
<input checked id="input_mode_2" name="input_mode" onclick="sync_input();" type="radio" value="2"> Pre-supply input:<br>
<textarea class="editsmall" id="edit_input" name="input" wrap="virtual"></textarea><br>
<br>
Output:<br>
<textarea class="editsmall" id="edit_output" name="output" wrap="virtual"></textarea><br>
<br></td>
<td>
<br>
<input id="button_run" onclick="bf_interpret(this.form.source.value, this.form.input.value);" type="button" value="Run">
<input id="button_debug" onclick="debug_toggle();" type="button" value="Start Debugger">
<input disabled id="button_step" onclick="run_step();" type="button" value="Single Step (n)">
<input disabled id="button_run_debug" onclick="run_debug();" type="button" value="Run To Breakpoint (c)">
<br><br>
Source Viewer:<br>
<pre class="viewer" id="progview"> </pre><br>
Opcode Explanation:<br>
<pre class="viewer" id="explanation"> </pre><br>
Memory Viewer:<br>
<pre class="viewer" id="memview"> </pre><br>
Stack Viewer:<br>
<pre class="viewer" id="stackview"> </pre><br>
Input Viewer:<br>
<pre class="viewer" id="inputview"> </pre><br>
Output Viewer:<br>
<pre class="viewer" id="outputview"> </pre><br>
<b>Note:</b> The hash ("#") character marks a breakpoint.
</td>
</tr>
<tr valign="top">
<td colspan="2">
Example programs taken from <a href="http://esoteric.sange.fi/brainfuck/">the Brainfuck Archive</a>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>