blob: 33812cbafe95fd257bee7d26b38786e07ea661e9 [file] [log] [blame]
<!DOCTYPE html>
<title>Searchable RISC-V instruction set reference</title>
<div class="wrapper">
<input type="text" id="searchbox" placeholder="Search RISC-V Instructions"></input>
</div>
<details>
<summary>Instruction format types</summary>
<ul>
<li>R - registers, <code>op rd, rs1, rs2</code>. 3 opcode
parts, <code>opcode, funct7, funct3</code></li>
<li>I - immediate, <code>op rd, rs1, imm[12]</code>. 2 opcode
parts, <code>opcode, funct3</code>. Except on ECALL when
it uses the immediate section for an opcode, called
funct12</li>
<li>S - store, <code>op, rs1, rs2+imm[12]</code>. 2 opcode
parts, <code>opcode</code> and <code>funct3</code>.</li>
<li>B - Variant of S type, probably means "branch". 2 opcode
parts, <code>opcode</code> and <code>funct3</code>.</li>
<li>U - upper load, <code>op rd, imm[20]</code>. 1 opcode
part, <code>opcode</code>.</li>
<li>J - Variant of J type, jump???. 1 opcode part, <code>opcode</code>.</li>
<li>pseudo - Pseudo-instruction</li>
</ul>
</details>
<div id="ilist">
</div>
<hr>
<p class="cite">
The listings in this searchable RISC-V instruction set reference
are generated from documentation written by <a href="https://hg.sr.ht/~icefox/riscv-reference">~icefox</a>
on sourcehut. Website created by <a href="https://swisschili.sh">swissChili</a>.
</p>
<p class="cite">
This documentation is incomplete for now. Check the ~icefox link
for what is currently implemented.
</p>
<style>
body {
font-family: sans-serif;
max-width: 50em;
margin: auto;
padding: 10px;
}
dt {
font-weight: bold;
}
dd div,
#searchbox,
code {
background: #fcfaf2;
padding: 4px;
border-radius: 4px;
border: 1px solid #f4f2e8;
}
code {
padding: 2px;
}
#searchbox {
font-size: 14pt;
padding: 12px 20px;
width: min-content;
}
.wrapper {
width: 100%;
display: flex;
justify-content: center;
margin-bottom: 4em;
margin-top: 2em;
}
.cite {
font-style: italic;
text-align: center;
}
hr {
border-color: #CCC;
}
details {
margin-bottom: 2em;
}
summary {
cursor: pointer;
}
</style>
<script>
function setup(instructions)
{
console.log(instructions);
function handler()
{
let html = "";
console.log("searched");
let q = searchbox.value.toLowerCase();
console.log({q});
for (let item of instructions)
{
if (!item.mnemonic.toLowerCase().includes(q) &&
!item.name.toLowerCase().includes(q))
continue;
let desc = item.long_description.replace("\n\n", "</p><p>");
html += `
<dt>${item.mnemonic} - ${item.name}</dt>
<dd>
<div>encoding: ${item.encoding}, extension: ${item.extension}, opcode: ${item.opcode}</div>
<p>${desc}</p>
</dd>
`;
}
ilist.innerHTML = html;
};
searchbox.addEventListener("input", handler);
handler();
}
fetch("instructions.json")
.then(res => res.json())
.then(setup);
</script>