-
Notifications
You must be signed in to change notification settings - Fork 3
/
PicoBlaze.html
236 lines (236 loc) · 9.97 KB
/
PicoBlaze.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html lang="en">
<head>
<title>PicoBlaze Simulator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="An on-line simulator for Xilinx PicoBlaze, runnable in a modern browser (starting with Firefox 52)."
/>
<meta name="author" content="Teo Samarzija" />
<link rel="stylesheet" href="styles.css" />
<script id="objectAssignPolyfill"></script>
<script id="symbolPolyfill"></script>
<script id="fetchPolyfill"></script>
<script id="BabelJS"></script>
<script id="BabelPolyfill"></script>
<script>
var URL_of_JSON_with_examples =
"https://flatassembler.github.io/PicoBlaze/examples.json",
URL_prefix_of_the_examples =
"https://raw.githubusercontent.com/FlatAssembler/PicoBlaze_Simulator_in_JS/master/";
</script>
<script src="headerScript.js" type="text/javascript"></script>
<script src="TreeNode.js" type="text/javascript"></script>
<script src="tokenizer.js" type="text/javascript"></script>
<script src="parser.js" type="text/javascript"></script>
<script src="preprocessor.js" type="text/javascript"></script>
<script src="assembler.js" type="text/javascript"></script>
<script src="simulator.js" type="text/javascript"></script>
</head>
<body>
<header>
<h1>PicoBlaze Simulator</h1>
Made by Teo Samaržija.
</header>
<main>
<div id="lineNumbers">1.</div>
<pre id="assemblyCode" contenteditable="true">
;Insert PicoBlaze assembly here...
</pre
>
<div id="divWithExamples">
<span id="examplesSpan">Examples:</span>
<div id="examples">
<span id="fetchingExamples">
Fetching the examples from GitHub...
</span>
</div>
</div>
<div id="buttons">
<button id="highlightButton">Highlight Assembly</button>
<button id="assembleButton">Assemble</button>
</div>
<div id="divWithMachineCode">
<div id="warningAboutJavaScript">
Your browser doesn't seem to support modern JavaScript, needed for
this web-app!<br />
I would recommend you to use
<a href="https://www.torproject.org/">The TOR Browser</a>. Modern
JavaScript executes the fastest in it, as fast as in
<a href="https://www.mozilla.org/en-US/">Firefox</a>, but TOR Browser
protects privacy significantly more.<br />Please consider that, if too
few people use tools for protecting privacy on the Internet, using
them is considered suspicious. Participating in a system that does not
respect privacy is putting everybody in danger of mass surveillance
and predictive policing. Even if you think you have nothing to hide,
please think of others (and learn about senseless laws and red flags
that apply to you).<br />
My
<a href="https://flatassembler.github.io/compiler.html"
>web-app that converts arithmetic expressions to x86 assembly</a
>
can run in ancient browsers, in case you want to try it.<br />
Or, you can try
<a href="javascript:void(0)" onclick="downloadBabel()"
>polyfilling your browser with BabelJS</a
>.
</div>
</div>
<script>
function downloadBabel() {
document.getElementById("objectAssignPolyfill").src =
"https://cdn.jsdelivr.net/npm/object-assign-polyfill/index.min.js";
document.getElementById("symbolPolyfill").src =
"https://cdn.jsdelivr.net/npm/symbol-es6/symbol-es6.min.js";
document.getElementById("BabelPolyfill").src =
"https://unpkg.com/@babel/polyfill/dist/polyfill.js";
/*
Do not include the minified file, because Babel Minifier
transpiles "RegExp('x','y')" into "/x/y", which is a syntax
error in Internet Explorer 11!
*/
document.getElementById("BabelJS").src =
"https://unpkg.com/@babel/standalone/babel.min.js";
document.getElementById("fetchPolyfill").src =
"https://cdn.jsdelivr.net/npm/[email protected]/dist/fetch.umd.min.js";
var scripts = document.getElementsByTagName("script");
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].type == "text/javascript") {
var newScriptTag = document.createElement("script");
newScriptTag.type = "text/babel";
newScriptTag.src = scripts[i].src;
newScriptTag.setAttribute("async", false);
newScriptTag.innerHTML = scripts[i].innerHTML;
document.body.appendChild(newScriptTag);
}
}
}
</script>
<div id="simulationButtons">
<button id="playPauseButton">
<img
src="play.svg"
alt="play"
id="playImage"
style="display: inline"
/>
<img
src="pause.svg"
alt="pause"
id="pauseImage"
style="display: none"
/>
<span class="tooltip">Play/Pause</span>
<!--Didn't know modern browsers don't display alts automatically
when you hover over an image.-->
</button>
<button id="fastForwardButton">
<img src="fastForward.svg" alt="Fast Forward" />
<span class="tooltip">Fast Forward</span>
</button>
<button id="singleStepButton">
<img src="singleStep.svg" alt="Single Step" />
<span class="tooltip">Single Step</span>
</button>
<button id="stopButton">
<svg width="30" height="30" alt="stop">
<defs>
<radialGradient id="redGradient">
<stop offset="0%" stop-color="rgb(64,0,0)" />
<stop offset="75%" stop-color="black" />
</radialGradient>
</defs>
<polygon points="0,0 30,0 30,30 0,30" fill="url(#redGradient)" />
</svg>
<span class="tooltip">Stop</span>
</button>
</div>
<div id="graphicalResults"></div>
<button id="UART_enable_button">
<span id="enable_or_disable_UART">Enable</span>
<abbr title="Universal Asynchronous Receiver-Transmitter">UART</abbr>
terminal
</button>
<div id="UART_IO">
<label for="UART_INPUT"
>UART input (<i>enter <b>before</b> starting</i>):</label
>
<textarea id="UART_INPUT"></textarea>
<label for="UART_OUTPUT">UART output:</label>
<pre id="UART_OUTPUT"></pre>
</div>
<div id="simulationResults"></div>
</main>
<footer>
Not affiliated with
<a
href="https://www.xilinx.com/products/intellectual-property/picoblaze.html"
>Xilinx PicoBlaze</a
>. If you want to contribute,
<a href="https://github.com/FlatAssembler/PicoBlaze_Simulator_in_JS"
>fork me on GitHub</a
>. Exceptionally helpful would be contributions to
<a href="https://github.com/FlatAssembler/PicoBlaze_Simulator_for_Android"
>the Android version of this simulator</a
>, as I am not an experienced Android developer. If you would like to know
more about me, visit my
<a href="https://flatassembler.github.io/">homepage</a>. The documentation
for this simulator is available in
<a href="PicoBlaze.rtf">this <abbr title="Rich Text Format">RTF</abbr></a>
(saved from Microsoft Office Word 2007, some other formats are available
on GitHub as well). For now, the documentation is only available in
Croatian. If you are willing to spend your time translating it to English
(better than machine translation), contact me on GitHub or
<a href="javascript:void(0)" onclick="sendMail('Teo')"
>send me an e-mail</a
>. Also, maybe it would be a good idea to implement some back-end on
<a href="https://picoblaze-simulator.sourceforge.io/">SourceForge</a> so
that people can comment on and share PicoBlaze programs, given that
SourceForge lets us run PHP on their servers for free.
<script>
//Copied from: https://flatassembler.github.io/compiler
//I have written that many years ago...
function sendMail(whom) {
var sifrirano;
if (whom == "Tomasz")
sifrirano = [
6, 2, 36, 28, 1, 42, 17, 21, 23, 50, 54, 9, 21, 17, 19, 35, 17,
22, 8, 16, 60, 0, 6, 75, 28, 53, 17
];
else if (whom == "Teo")
sifrirano = [
27, 0, 36, 75, 1, 49, 8, 21, 23, 8, 57, 15, 21, 37, 21, 61, 29, 4,
9, 92, 51, 10, 25
];
var tmp = sifrirano[0];
sifrirano[0] = sifrirano[2];
sifrirano[2] = tmp;
tmp = sifrirano[17];
sifrirano[17] = sifrirano[16];
sifrirano[16] = tmp;
var hash2;
if (whom == "Teo") hash2 = 554;
else if (whom == "Tomasz") hash2 = 603;
var kljuc = prompt(
"Spambot protection problem: What is the name of the fictional character who had a spell casted on him so that he couldn't grow up, and he had to fight against the pirates? His nickname is 'Pan'.",
"His name without 'Pan'."
);
var desifrirano = [];
for (var i = 0; i < sifrirano.length; i++)
desifrirano.push(sifrirano[i] ^ kljuc.charCodeAt(i % kljuc.length));
var hash1 = 0;
for (var i = 0; i < desifrirano.length; i++)
hash1 = (hash1 * 128 + desifrirano[i]) % 907;
if (hash1 == hash2) {
var email = "";
for (var i = 0; i < desifrirano.length; i++)
email += String.fromCharCode(desifrirano[i]);
window.location.assign("mailto:" + email);
} else alert("Unfortunately, you didn't give the expected answer.");
}
</script>
</footer>
<script src="footerScript.js" type="text/javascript"></script>
</body>
</html>