This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathemulator.html
63 lines (58 loc) · 1.68 KB
/
emulator.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
<!DOCTYPE html>
<html>
<head>
<title>dcpu-16 emulator</title>
<script type="text/javascript" src="emulator.js"></script>
<script type="text/javascript" src="assembler.js"></script>
<script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="editor.js"></script>
<link rel="stylesheet" type="text/css" href="emulator.css" />
</head>
<body onload="display.begin( emulator, document.getElementById( 'display' ) );">
<canvas id="display"></canvas>
<br />
<input type="button" value="Assemble and Load" onclick="emulator.stop(); emulator.reset(); emulator.load( assembler.assemble( document.getElementById( 'code' ).value ) );"/>
<input type="button" value="Start" onclick="emulator.run();"/>
<input type="button" value="Stop" onclick="emulator.stop();"/>
<input type="button" value="Reset" onclick="emulator.reset();"/>
<select onchange="document.getElementById( 'code' ).innerText = document.getElementById( this.value ).innerText;">
<option value="blank.asm">[Blank]</option>
<option value="notch-hello.asm">Notch's Hello World</option>
</select>
<br />
<textarea id="code">
</textarea>
<pre style="display: none;" id="blank.asm"></pre>
<pre style="display: none;" id="notch-hello.asm">
; Assembler test for DCPU
; by Markus Persson
:start
set i, 0
set j, 0
set b, 0xf100
:nextchar
set a, (data+i)
ife a, 0
set PC, end
ifg a, 0xff
set PC, setcolor
bor a, b
set (0x8000+j), a
add i, 1
add j, 1
set PC, nextchar
:setcolor
set b, a
and b, 0xff
shl b, 8
ifg a, 0x1ff
add b, 0x80
add i, 1
set PC, nextchar
:data
dat 0x170, "Hello ", 0x2e1, "world", 0x170, ", how are you?", 0
:end
set PC, start
</pre>
</body>
</html>