This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
224 lines (212 loc) · 9.46 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
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
<!DOCTYPE html>
<!--
Modified from Dr K. G. Smitha's OPCoder:
https://personal.ntu.edu.sg/smitha/OPCoder/OPCoder/converter.html
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/css/bootstrap.min.css"
integrity="sha512-GQGU0fMMi238uA+a/bdWJfpUGKUkBdgfFdgBm72SUQ6BeyWjoY/ton0tEjH+OSH9iP4Dfh+7HM0I9f5eR0L/4w=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<title> Opcoder </title>
</head>
<body>
<div class="container-lg py-3">
<div class="container-lg py-3">
<h1> Opcoder </h1>
<p class="text-muted">
Modified from Dr K. G. Smitha's
<a href="https://personal.ntu.edu.sg/smitha/OPCoder/OPCoder/converter.html">OPCoder</a>
</p>
</div>
<div class="container-sm py-3">
<div class="accordion" id="accordionOpcodes">
<div class="accordion-item">
<h2 class="accordion-header" id="headingOpcodes">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseOpcodes" aria-expanded="true" aria-controls="collapseOpcodes">
Opcodes
</button>
</h2>
<div id="collapseOpcodes" class="accordion-collapse collapse" aria-labelledby="headingOpcodes"
data-bs-parent="#accordionOpcodes">
<div class="accordion-body">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Instruction</th>
<th scope="col">Opcode</th>
</tr>
</thead>
<tbody style="font-family: monospace;">
<tr>
<td>ADD</td>
<td>00000000000</td>
</tr>
<tr>
<td>SUB</td>
<td>00000000001</td>
</tr>
<tr>
<td>AND</td>
<td>00000000010</td>
</tr>
<tr>
<td>XOR</td>
<td>00000000011</td>
</tr>
<tr>
<td>ORR</td>
<td>00000000100</td>
</tr>
<tr>
<td>LDUR</td>
<td>00000000101</td>
</tr>
<tr>
<td>STUR</td>
<td>00000000110</td>
</tr>
<tr>
<td>CBZ</td>
<td>00000111</td>
</tr>
<tr>
<td>B</td>
<td>001000</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="container-lg">
<div class="row">
<div class="col-sm py-3">
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="input"
style="font-family: monospace; height: 240px"></textarea>
<label for="input">Input</label>
</div>
</div>
<div class="col-sm py-3">
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="result"
style="font-family: monospace; height: 240px; background-color:transparent;"
readonly="readonly"></textarea>
<label for="result">Result</label>
</div>
</div>
</div>
</div>
<div class="container-lg py-3">
<h2> Syntax </h2>
<p><code>
ADD X5, X5, X6 // ADD<br>
LDUR X5, [X2, #0] // LDUR<br>
CBZ X7, #3 // CBZ<br>
B #4 // B<br>
STUR X5, [X2, #2] // STUR<br>
</code></p>
<p>
Lines with syntax error are ignored.
</p>
</div>
<div class="container-lg py-3">
<h2> Reference </h2>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h3> Instruction Format </h3>
<table class="table table-bordered">
<thead>
<th scope="col">Type</th>
<th scope="col" colspan=5>Format (32 bits)</th>
</thead>
<tr>
<th scope="row">R</th>
<td>Opcode(11)</td>
<td>Rm(5)</td>
<td>shamt(6)</td>
<td>Rn(5)</td>
<td>Rd(5)</td>
</tr>
<tr>
<th scope="row">D</th>
<td>Opcode(11)</td>
<td>address(9)</td>
<td>op2(2)</td>
<td>Rn(5)</td>
<td>Rt(5)</td>
</tr>
<tr>
<th scope="row">CB</th>
<td>Opcode(8)</td>
<td colspan=3>address(19)</td>
<td>Rt(5)</td>
</tr>
<tr>
<th scope="row">B</th>
<td>Opcode(6)</td>
<td colspan=4>address(26)</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-body">
<h3> Instructions </h3>
<table class="table table-bordered">
<thead>
<th scope="col">Type</th>
<th scope="col">Instructions</th>
</thead>
<tr>
<th>R</th>
<td>ADD, SUB, AND, XOR, ORR</td>
</tr>
<tr>
<th>D</th>
<td>LDUR, STUR </td>
</tr>
<tr>
<th>CB</th>
<td>CBZ</td>
</tr>
<tr>
<th>B</th>
<td>B</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="module">
import { convert } from "./opcoder.js";
function convertLines(lines) {
return lines
.split("\n")
.map(line => (line.trim().length !== 0)
? `${convert(line).toUpperCase()} // ${line}`
: line);
}
document.getElementById("input").addEventListener("input", e => {
const lines = document.getElementById("input").value;
document.getElementById("result").value = convertLines(lines).join("\n");
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.bundle.min.js"
integrity="sha512-pax4MlgXjHEPfCwcJLQhigY7+N8rt6bVvWLFyUMuxShv170X53TRzGPmPkZmGBhk+jikR8WBM4yl7A9WMHHqvg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</body>
</html>