swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | |
swissChili | b692b47 | 2022-07-16 22:13:22 -0700 | [diff] [blame] | 3 | <title>Searchable RISC-V instruction set reference</title> |
| 4 | |
swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 5 | <div class="wrapper"> |
| 6 | <input type="text" id="searchbox" placeholder="Search RISC-V Instructions"></input> |
| 7 | </div> |
| 8 | |
swissChili | b692b47 | 2022-07-16 22:13:22 -0700 | [diff] [blame] | 9 | <details> |
| 10 | <summary>Instruction format types</summary> |
| 11 | |
| 12 | <ul> |
| 13 | <li>R - registers, <code>op rd, rs1, rs2</code>. 3 opcode |
| 14 | parts, <code>opcode, funct7, funct3</code></li> |
| 15 | |
| 16 | <li>I - immediate, <code>op rd, rs1, imm[12]</code>. 2 opcode |
| 17 | parts, <code>opcode, funct3</code>. Except on ECALL when |
| 18 | it uses the immediate section for an opcode, called |
| 19 | funct12</li> |
| 20 | |
| 21 | <li>S - store, <code>op, rs1, rs2+imm[12]</code>. 2 opcode |
| 22 | parts, <code>opcode</code> and <code>funct3</code>.</li> |
| 23 | |
| 24 | <li>B - Variant of S type, probably means "branch". 2 opcode |
| 25 | parts, <code>opcode</code> and <code>funct3</code>.</li> |
| 26 | |
| 27 | <li>U - upper load, <code>op rd, imm[20]</code>. 1 opcode |
| 28 | part, <code>opcode</code>.</li> |
| 29 | |
| 30 | <li>J - Variant of J type, jump???. 1 opcode part, <code>opcode</code>.</li> |
| 31 | |
| 32 | <li>pseudo - Pseudo-instruction</li> |
| 33 | </ul> |
| 34 | </details> |
| 35 | |
swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 36 | <div id="ilist"> |
| 37 | </div> |
| 38 | |
| 39 | <hr> |
| 40 | |
| 41 | <p class="cite"> |
swissChili | b692b47 | 2022-07-16 22:13:22 -0700 | [diff] [blame] | 42 | The listings in this searchable RISC-V instruction set reference |
| 43 | are generated from documentation written by <a href="https://hg.sr.ht/~icefox/riscv-reference">~icefox</a> |
swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 44 | on sourcehut. Website created by <a href="https://swisschili.sh">swissChili</a>. |
| 45 | </p> |
| 46 | <p class="cite"> |
| 47 | This documentation is incomplete for now. Check the ~icefox link |
| 48 | for what is currently implemented. |
| 49 | </p> |
| 50 | |
| 51 | <style> |
| 52 | body { |
| 53 | font-family: sans-serif; |
| 54 | max-width: 50em; |
| 55 | margin: auto; |
| 56 | padding: 10px; |
| 57 | } |
| 58 | |
| 59 | dt { |
| 60 | font-weight: bold; |
| 61 | } |
| 62 | |
| 63 | dd div, |
swissChili | b692b47 | 2022-07-16 22:13:22 -0700 | [diff] [blame] | 64 | #searchbox, |
| 65 | code { |
swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 66 | background: #fcfaf2; |
| 67 | padding: 4px; |
| 68 | border-radius: 4px; |
| 69 | border: 1px solid #f4f2e8; |
| 70 | } |
| 71 | |
swissChili | b692b47 | 2022-07-16 22:13:22 -0700 | [diff] [blame] | 72 | code { |
| 73 | padding: 2px; |
| 74 | } |
| 75 | |
swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 76 | #searchbox { |
| 77 | font-size: 14pt; |
| 78 | padding: 12px 20px; |
| 79 | width: min-content; |
| 80 | } |
| 81 | |
| 82 | .wrapper { |
| 83 | width: 100%; |
| 84 | display: flex; |
| 85 | justify-content: center; |
| 86 | margin-bottom: 4em; |
| 87 | margin-top: 2em; |
| 88 | } |
| 89 | |
| 90 | .cite { |
| 91 | font-style: italic; |
| 92 | text-align: center; |
| 93 | } |
| 94 | |
| 95 | hr { |
| 96 | border-color: #CCC; |
| 97 | } |
swissChili | b692b47 | 2022-07-16 22:13:22 -0700 | [diff] [blame] | 98 | |
| 99 | details { |
| 100 | margin-bottom: 2em; |
| 101 | } |
| 102 | |
| 103 | summary { |
| 104 | cursor: pointer; |
| 105 | } |
swissChili | 1c16681 | 2022-07-16 21:57:06 -0700 | [diff] [blame] | 106 | </style> |
| 107 | |
| 108 | <script> |
| 109 | function setup(instructions) |
| 110 | { |
| 111 | console.log(instructions); |
| 112 | |
| 113 | function handler() |
| 114 | { |
| 115 | let html = ""; |
| 116 | |
| 117 | console.log("searched"); |
| 118 | |
| 119 | let q = searchbox.value.toLowerCase(); |
| 120 | |
| 121 | console.log({q}); |
| 122 | |
| 123 | for (let item of instructions) |
| 124 | { |
| 125 | if (!item.mnemonic.toLowerCase().includes(q) && |
| 126 | !item.name.toLowerCase().includes(q)) |
| 127 | continue; |
| 128 | |
| 129 | let desc = item.long_description.replace("\n\n", "</p><p>"); |
| 130 | |
| 131 | html += ` |
| 132 | <dt>${item.mnemonic} - ${item.name}</dt> |
| 133 | <dd> |
| 134 | <div>encoding: ${item.encoding}, extension: ${item.extension}, opcode: ${item.opcode}</div> |
| 135 | <p>${desc}</p> |
| 136 | </dd> |
| 137 | `; |
| 138 | } |
| 139 | |
| 140 | ilist.innerHTML = html; |
| 141 | }; |
| 142 | |
| 143 | searchbox.addEventListener("input", handler); |
| 144 | handler(); |
| 145 | } |
| 146 | |
| 147 | fetch("instructions.json") |
| 148 | .then(res => res.json()) |
| 149 | .then(setup); |
| 150 | </script> |