├── LICENSE ├── README.md ├── img ├── sample.gif └── sample2.gif ├── pseudo ├── beqz.md ├── bgez.md ├── bgt.md ├── bgtu.md ├── bgtz.md ├── ble.md ├── bleu.md ├── blez.md ├── bltz.md ├── bnez.md ├── call.md ├── csrc.md ├── csrci.md ├── csrr.md ├── csrs.md ├── csrsi.md ├── csrw.md ├── csrwi.md ├── fence.md ├── fl.md ├── fs.md ├── j.md ├── jal.md ├── jalr.md ├── jr.md ├── l.md ├── la.md ├── li.md ├── lla.md ├── mv.md ├── neg.md ├── negw.md ├── nop.md ├── not.md ├── rdcycle.md ├── rdinstret.md ├── rdtime.md ├── ret.md ├── s.md ├── sext.md ├── sgtz.md ├── sltz.md ├── snez.md └── tail.md └── rv32i ├── add.md ├── and.md ├── auipc.md ├── beq.md ├── bge.md ├── blt.md ├── bne.md ├── csrrc.md ├── csrrs.md ├── csrrw.md ├── ebreak.md ├── ecall.md ├── fence.md ├── jal.md ├── jalr.md ├── lb.md ├── ld.md ├── lh.md ├── lui.md ├── lw.md ├── mret.md ├── or.md ├── sb.md ├── sh.md ├── sll.md ├── slt.md ├── sra.md ├── sret.md ├── srl.md ├── sub.md ├── sw.md ├── wfi.md └── xor.md /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # riscv_tldr 2 | tldr file for riscv assembly instructions 3 | 这是一份基于tldr的riscv汇编指令文件库,将其安装在tldr后,可以通过tldr进行riscv汇编指令的查询。 4 | 目前支持RV32I和汇编伪指令。 5 | 6 | ## 安装 7 | > cd ~ 8 | > git clone https://github.com/lgl88911/riscv_tldr.git 9 | 10 | > sudo apt-get install tldr 11 | 12 | > cp riscv_tldr/rv32i/* ~/.tldr/tldr/pages/common/ 13 | 14 | > cp riscv_tldr/pseudo/* ~/.tldr/tldr/pages/common/ 15 | 16 | ## 使用 17 | 和tldr一样简单 18 | > tldr met 19 | ![](https://github.com/lgl88911/riscv_tldr/blob/master/img/sample.gif) 20 | 21 | 如果没有查找到指令,请尝试缩短查找词,只找有意义的关键词例如 22 | >tldr addi 23 | 找不到就用 24 | >tldr add 25 | ![](https://github.com/lgl88911/riscv_tldr/blob/master/img/sample2.gif) 26 | 27 | 28 | ## 贡献和Issue 29 | 欢迎修改错误和提交Issue 30 | 31 | -------------------------------------------------------------------------------- /img/sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lgl88911/riscv_tldr/f4b6935ada09fdf9c40f4fe4d61277b339107e6e/img/sample.gif -------------------------------------------------------------------------------- /img/sample2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lgl88911/riscv_tldr/f4b6935ada09fdf9c40f4fe4d61277b339107e6e/img/sample2.gif -------------------------------------------------------------------------------- /pseudo/beqz.md: -------------------------------------------------------------------------------- 1 | # beqz 2 | 3 | > 伪指令,为0跳转. 4 | 5 | - 寄存器rs值为0时跳转到offset: 6 | 7 | `beqz rs, offset` 8 | 9 | - 实例: 10 | 11 | `beqz s0, lable1` 12 | -------------------------------------------------------------------------------- /pseudo/bgez.md: -------------------------------------------------------------------------------- 1 | # bgez 2 | 3 | > 伪指令,大于等于0跳转. 4 | 5 | - 寄存器rs值大于等于0时跳转到offset: 6 | 7 | `bgez rs, offset` 8 | 9 | - 实例: 10 | 11 | `bgez s0, lable2` 12 | -------------------------------------------------------------------------------- /pseudo/bgt.md: -------------------------------------------------------------------------------- 1 | # bgt 2 | 3 | > 伪指令,大于跳转. 4 | 5 | - 寄存器rs值大于rt时跳转到offset: 6 | 7 | `bgt rs, rt, offset` 8 | 9 | - 实例: 10 | 11 | `bgt s0, s1, lable2` -------------------------------------------------------------------------------- /pseudo/bgtu.md: -------------------------------------------------------------------------------- 1 | # bgtu 2 | 3 | > 伪指令,无符号大于跳转. 4 | 5 | - 以无符号比较,寄存器rs值大于rt时跳转到offset: 6 | 7 | `bgtu rs, rt, offset` 8 | 9 | - 实例: 10 | 11 | `bgtu s0, s1, lable2` 12 | -------------------------------------------------------------------------------- /pseudo/bgtz.md: -------------------------------------------------------------------------------- 1 | # bgtz 2 | 3 | > 伪指令,大于0跳转. 4 | 5 | - 寄存器rs值大于0时跳转到offset: 6 | 7 | `bgtz rs, offset` 8 | 9 | - 实例: 10 | 11 | `bgtz s0, lable2` -------------------------------------------------------------------------------- /pseudo/ble.md: -------------------------------------------------------------------------------- 1 | # ble 2 | 3 | > 伪指令,小于等于跳转. 4 | 5 | - 寄存器rs值小于等于rt时跳转到offset: 6 | 7 | `ble rs, rt, offset` 8 | 9 | - 实例: 10 | 11 | `ble s0, s1, lable2` 12 | -------------------------------------------------------------------------------- /pseudo/bleu.md: -------------------------------------------------------------------------------- 1 | # ble 2 | 3 | > 伪指令,无符号小于等于跳转. 4 | 5 | - 以无符号比较,寄存器rs值小于等于rt时跳转到offset: 6 | 7 | `bleu rs, rt, offset` 8 | 9 | - 实例: 10 | 11 | `bleu s0, s1, lable2` 12 | -------------------------------------------------------------------------------- /pseudo/blez.md: -------------------------------------------------------------------------------- 1 | # blez 2 | 3 | > 伪指令,小于等于0跳转. 4 | 5 | - 寄存器rs值小于等于0时跳转到offset: 6 | 7 | `blez rs, offset` 8 | 9 | - 实例: 10 | 11 | `blez s0, lable2` 12 | -------------------------------------------------------------------------------- /pseudo/bltz.md: -------------------------------------------------------------------------------- 1 | # bltz 2 | 3 | > 伪指令,小于0跳转. 4 | 5 | - 寄存器rs值小于0时跳转到offset: 6 | 7 | `bltz rs, offset` 8 | 9 | - 实例: 10 | 11 | `bltz s0, lable2` -------------------------------------------------------------------------------- /pseudo/bnez.md: -------------------------------------------------------------------------------- 1 | # bnez 2 | 3 | > 伪指令,非0跳转. 4 | 5 | - 寄存器rs值为0时跳转到offset: 6 | 7 | `bnez rs, offset` 8 | 9 | - 实例: 10 | 11 | `beqz s0, lable2` 12 | -------------------------------------------------------------------------------- /pseudo/call.md: -------------------------------------------------------------------------------- 1 | # call 2 | 3 | > 伪指令,远程调用过程(地址是32bit). 4 | 5 | - 跳转到offset执行,并将跳转指令的下一条指令地址放入ra寄存器: 6 | 7 | `call offset` 8 | 9 | - 实例: 10 | 11 | `call lable` 12 | -------------------------------------------------------------------------------- /pseudo/csrc.md: -------------------------------------------------------------------------------- 1 | # csrc 2 | 3 | > 伪指令,CSR寄存器位清0. 4 | 5 | - CSR寄存器按照rs位清0,csr = csr & rs: 6 | 7 | `csrc csr, rs` 8 | 9 | - 实例: 10 | 11 | `csrc mie, t0` 12 | -------------------------------------------------------------------------------- /pseudo/csrci.md: -------------------------------------------------------------------------------- 1 | # csrci 2 | 3 | > 伪指令,CSR立即数位清0. 4 | 5 | - CSR寄存器按照立即数位清0,csr = csr & imm: 6 | 7 | `csrci csr, imm` 8 | 9 | - 实例: 10 | 11 | `csrci mie, 0b11110111` 12 | -------------------------------------------------------------------------------- /pseudo/csrr.md: -------------------------------------------------------------------------------- 1 | # csrr 2 | 3 | > 伪指令,读CSR. 4 | 5 | - 将CSR寄存器内容读到寄存器rd中: 6 | 7 | `csrr rd, csr` 8 | 9 | - 实例: 10 | 11 | `csrr t0, csr` 12 | -------------------------------------------------------------------------------- /pseudo/csrs.md: -------------------------------------------------------------------------------- 1 | # csrs 2 | 3 | > 伪指令,CSR寄存器置位. 4 | 5 | - CSR寄存器按照rs置位,csr = csr | rs: 6 | 7 | `csrs csr, rs` 8 | 9 | - 实例: 10 | 11 | `csrs mie, t0` 12 | -------------------------------------------------------------------------------- /pseudo/csrsi.md: -------------------------------------------------------------------------------- 1 | # csrsi 2 | 3 | > 伪指令,CSR立即数置位. 4 | 5 | - CSR寄存器按照立即数置位,csr = csr | imm: 6 | 7 | `csrsi csr, imm` 8 | 9 | - 实例: 10 | 11 | `csrs mie, 0b10` 12 | -------------------------------------------------------------------------------- /pseudo/csrw.md: -------------------------------------------------------------------------------- 1 | # csrw 2 | 3 | > 伪指令,写CSR. 4 | 5 | - 将寄存器rs的值写入到csr中: 6 | 7 | `csrw csr, rs` 8 | 9 | - 实例: 10 | 11 | `csrw csr, t0` 12 | -------------------------------------------------------------------------------- /pseudo/csrwi.md: -------------------------------------------------------------------------------- 1 | # csrwi 2 | 3 | > 伪指令,写立即数到CSR. 4 | 5 | - 将立即数imm写入到csr中: 6 | 7 | `csrwi csr, rs` 8 | 9 | - 实例: 10 | 11 | `csrw csr, t0` 12 | -------------------------------------------------------------------------------- /pseudo/fence.md: -------------------------------------------------------------------------------- 1 | # fence 2 | 3 | > 伪指令,内存和IO屏障. 4 | 5 | - 内存和IO屏障,保证fence之前的指令执行完后才执行fence之后的指令: 6 | 7 | `fence` 8 | 9 | - 实例: 10 | 11 | `fence` 12 | -------------------------------------------------------------------------------- /pseudo/fl.md: -------------------------------------------------------------------------------- 1 | # fl{w|d} 2 | 3 | > 伪指令,读取浮点全局量. 4 | 5 | - 将字浮点量symbol读取到寄存器rd中: 6 | 7 | `flw rd, symbol, rt` 8 | 9 | - 将双字浮点量symbol读取到寄存器rd中: 10 | 11 | `fld rd, symbol, rt` 12 | 13 | - 实例: 14 | 15 | `` 16 | -------------------------------------------------------------------------------- /pseudo/fs.md: -------------------------------------------------------------------------------- 1 | # fs{w|d} 2 | 3 | > 伪指令,存储浮点全局量. 4 | 5 | - 将rd中的字浮点量写入到symbol中: 6 | 7 | `fsw rd, symbol, rt` 8 | 9 | - 将rd中的双字字浮点量写入到symbol中: 10 | 11 | `fsd rd, symbol, rt` 12 | 13 | - 实例: 14 | 15 | `` 16 | -------------------------------------------------------------------------------- /pseudo/j.md: -------------------------------------------------------------------------------- 1 | # j 2 | 3 | > 伪指令,跳转. 4 | 5 | - 跳转到offset处执行: 6 | 7 | `j offset` 8 | 9 | - 实例: 10 | 11 | `j lable1` 12 | -------------------------------------------------------------------------------- /pseudo/jal.md: -------------------------------------------------------------------------------- 1 | # jal 2 | 3 | > 伪指令,跳转并链接. 4 | 5 | - 跳转到offset执行,并将跳转指令的下一条指令地址放入ra寄存器: 6 | 7 | `jal offset` 8 | 9 | - 实例: 10 | 11 | `jal lable` 12 | -------------------------------------------------------------------------------- /pseudo/jalr.md: -------------------------------------------------------------------------------- 1 | # jalr 2 | 3 | > 伪指令,跳转并链接寄存器. 4 | 5 | - 跳转到寄存器rs所存储的地址处执行,并将跳转指令的下一条指令地址放入ra寄存器: 6 | 7 | `jalr rs` 8 | 9 | - 实例: 10 | 11 | `jalr s0` 12 | -------------------------------------------------------------------------------- /pseudo/jr.md: -------------------------------------------------------------------------------- 1 | # jr 2 | 3 | > 伪指令,寄存器跳转. 4 | 5 | - 跳转到寄存器rs所存储的地址处执行: 6 | 7 | `jr rs` 8 | 9 | - 实例: 10 | 11 | `jr s0` 12 | -------------------------------------------------------------------------------- /pseudo/l.md: -------------------------------------------------------------------------------- 1 | # l{b|h|w|d} 2 | 3 | > 伪指令,读取全局量. 4 | 5 | - 将字节量symbol读取到寄存器rd中: 6 | 7 | `lb rd, symbol` 8 | 9 | - 将半字量symbol读取到寄存器rd中: 10 | 11 | `lh rd, symbol` 12 | 13 | - 将字量symbol读取到寄存器rd中: 14 | 15 | `lw rd, symbol` 16 | 17 | - 将双字量symbol读取到寄存器rd中: 18 | 19 | `ld rd, symbol` 20 | 21 | 22 | - 实例: 23 | 24 | `lb s0, vbyte` 25 | `lh s0, vhalf` 26 | `lw s0, vword` 27 | `ld s0, vdword` 28 | -------------------------------------------------------------------------------- /pseudo/la.md: -------------------------------------------------------------------------------- 1 | # la 2 | 3 | > 伪指令,获符号地址. 4 | 5 | - 将变量symbol的地址放入寄存器rd中: 6 | 7 | `la rd, symbol` 8 | 9 | - 实例: 10 | 11 | `la s0, tmp` 12 | -------------------------------------------------------------------------------- /pseudo/li.md: -------------------------------------------------------------------------------- 1 | # li 2 | 3 | > 伪指令,读取立即数. 4 | 5 | - 将立即数imm保存到寄存器rd中: 6 | 7 | `li rd, imm` 8 | 9 | - 实例: 10 | 11 | `li a0, 354` 12 | -------------------------------------------------------------------------------- /pseudo/lla.md: -------------------------------------------------------------------------------- 1 | # lla 2 | 3 | > 伪指令,获符号地址. 4 | 5 | - 将变量symbol的局部地址放入寄存器rd中: 6 | 7 | `lla rd, symbol` 8 | 9 | - 实例: 10 | 11 | `lla s0, tmp` 12 | -------------------------------------------------------------------------------- /pseudo/mv.md: -------------------------------------------------------------------------------- 1 | # mv 2 | 3 | > 伪指令,复制寄存器. 4 | 5 | - 将寄存器rs的内容复制到寄存器rd中: 6 | 7 | `mv rd, rs` 8 | 9 | - 实例: 10 | 11 | `mv s0, s1` 12 | -------------------------------------------------------------------------------- /pseudo/neg.md: -------------------------------------------------------------------------------- 1 | # neg 2 | 3 | > 伪指令,补码. 4 | 5 | - 将寄存器rs的补码放入到rd: 6 | 7 | `neg rs, rd` 8 | 9 | - 实例: 10 | 11 | `neg s0, a0` 12 | -------------------------------------------------------------------------------- /pseudo/negw.md: -------------------------------------------------------------------------------- 1 | # negw 2 | 3 | > 伪指令,字的补码. 4 | 5 | - 将寄存器rs的补码放入到rd: 6 | 7 | `negw rd, rs` 8 | 9 | - 实例: 10 | 11 | `negw s0, a0` 12 | -------------------------------------------------------------------------------- /pseudo/nop.md: -------------------------------------------------------------------------------- 1 | # nop 2 | 3 | > 伪指令,空指令. 4 | 5 | - 空指令,让CPU空转一个指令周期: 6 | 7 | `nop` 8 | 9 | -------------------------------------------------------------------------------- /pseudo/not.md: -------------------------------------------------------------------------------- 1 | # not 2 | 3 | > 伪指令,反码. 4 | 5 | - 将寄存器rs的值取反码放入寄存器rd中: 6 | 7 | `not rd, rs` 8 | 9 | - 实例: 10 | 11 | `not s0, a0` 12 | -------------------------------------------------------------------------------- /pseudo/rdcycle.md: -------------------------------------------------------------------------------- 1 | # rdcycle[h] 2 | 3 | > 伪指令,读取cycle寄存器(周期计数器). 4 | 5 | - 读取rdcycle寄存器值到rd: 6 | 7 | `rdcycle rd` 8 | 9 | - 读取rdcycle后右移32位后写入到rd: 10 | 11 | `rdcycleh rd` 12 | 13 | - 实例: 14 | 15 | `rdcycle t0` 16 | `rdcycleh t1` 17 | -------------------------------------------------------------------------------- /pseudo/rdinstret.md: -------------------------------------------------------------------------------- 1 | # rdinstret[h] 2 | 3 | > 伪指令,读取instret寄存器(已完成指令寄存器). 4 | 5 | - 读取instret寄存器值到rd: 6 | 7 | `rdinstret rd` 8 | 9 | - 读取rdinstret后右移32位后写入到rd: 10 | 11 | `rdinstreth rd` 12 | 13 | - 实例: 14 | 15 | `rdinstret t0` 16 | `rdinstreth t1` 17 | -------------------------------------------------------------------------------- /pseudo/rdtime.md: -------------------------------------------------------------------------------- 1 | # rdtime[h] 2 | 3 | > 伪指令,读取time寄存器. 4 | 5 | - 读取time寄存器值到rd: 6 | 7 | `rdtime rd` 8 | 9 | - 读取time后右移32位后写入到rd: 10 | 11 | `rdtimeh rd` 12 | 13 | - 实例: 14 | 15 | `rdtime t0` 16 | `rdtimeh t1` 17 | -------------------------------------------------------------------------------- /pseudo/ret.md: -------------------------------------------------------------------------------- 1 | # ret 2 | 3 | > 伪指令,从子程序返回. 4 | 5 | - 跳转到ra存储的地址处执行,和jar,jalr,call搭配使用完成函数调用: 6 | 7 | `ret` 8 | 9 | - 实例: 10 | 11 | `ret` 12 | -------------------------------------------------------------------------------- /pseudo/s.md: -------------------------------------------------------------------------------- 1 | # s{b|h|w|d} 2 | 3 | > 伪指令,写全局量. 4 | 5 | - 将寄存器rd的内容写入到字节量symbol中, rt为交换寄存器: 6 | 7 | `sb rd, symbol, rt` 8 | 9 | - 将寄存器rd的内容写入到半字量symbol中, rt为交换寄存器: 10 | 11 | `sh rd, symbol, rt` 12 | 13 | - 将寄存器rd的内容写入到字量symbol中, rt为交换寄存器: 14 | 15 | `sw rd, symbol, rt` 16 | 17 | - 将寄存器rd的内容写入到双字量symbol中, rt为交换寄存器: 18 | 19 | `sd rd, symbol, rt` 20 | 21 | 22 | - 实例: 23 | 24 | `sb a0, vbyte, t0` 25 | `sh a0, vhalf, t0` 26 | `sw a0, vword, t0` 27 | `sd a0, vdword, t0` 28 | -------------------------------------------------------------------------------- /pseudo/sext.md: -------------------------------------------------------------------------------- 1 | # sext.w 2 | 3 | > 伪指令,有符号扩展字. 目前发现gcc汇编器不能识别 4 | 5 | - 将寄存器rs的值进行有符号扩展为字,结果放入rd中: 6 | 7 | `sext.w rd, rs` 8 | 9 | - 实例: 10 | 11 | `` 12 | -------------------------------------------------------------------------------- /pseudo/sgtz.md: -------------------------------------------------------------------------------- 1 | # sgtz 2 | 3 | > 伪指令,大于0置1. 4 | 5 | - 如果rs大于0, rd被设置为1: 6 | 7 | `sgtz rd, rs` 8 | 9 | - 实例,a0小于等于0时s0为0, a0大于0时s0为1: 10 | 11 | `sltz s0, a0` 12 | -------------------------------------------------------------------------------- /pseudo/sltz.md: -------------------------------------------------------------------------------- 1 | # sltz 2 | 3 | > 伪指令,小于0置1. 4 | 5 | - 如果rs小于0, rd被设置为1: 6 | 7 | `sltz rd, rs` 8 | 9 | - 实例,a0大于等于0时s0为0, a0小于0时s0为1: 10 | 11 | `sltz s0, a0` 12 | -------------------------------------------------------------------------------- /pseudo/snez.md: -------------------------------------------------------------------------------- 1 | # snez 2 | 3 | > 伪指令,非0置1. 4 | 5 | - 如果rs不等于0, rd被设置为1: 6 | 7 | `snez rd, rs` 8 | 9 | - 实例,a0为0时s0为0, a0为1时s0为1: 10 | 11 | `snez s0, a0` 12 | -------------------------------------------------------------------------------- /pseudo/tail.md: -------------------------------------------------------------------------------- 1 | # tail 2 | 3 | > 伪指令,尾调用过程(地址是32bit). 4 | 5 | - 跳转到offset执行,不放任何东西进ra寄存器: 6 | 7 | `tail offset` 8 | 9 | - 实例: 10 | 11 | `tail lable` -------------------------------------------------------------------------------- /rv32i/add.md: -------------------------------------------------------------------------------- 1 | # add[i] 2 | 3 | > 加法. 4 | 5 | - 把寄存器 x[rs2]加到寄存器x[rs1]上,结果写入 x[rd]。 忽略算术溢出。 x[rd] = x[rs1] + x[rs2]: 6 | 7 | `add rd, rs1, rs2` 8 | 9 | - 把符号位扩展的立即数加到寄存器 x[rs1]上,结果写入 x[rd]。 忽略算术溢出。 x[rd] = x[rs1] + sext(immediate): 10 | 11 | `addi rd, rs1, immediate` 12 | 13 | - 实例: 14 | 15 | `add t0,t1,t2` 16 | `add t0,t1,100` 17 | -------------------------------------------------------------------------------- /rv32i/and.md: -------------------------------------------------------------------------------- 1 | # rdcycle[h] 2 | 3 | > 与. 4 | 5 | - 将寄存器 x[rs1]和寄存器x[rs2]位与的结果写入 x[rd]。 x[rd] = x[rs1] & x[rs2]: 6 | 7 | `and rd, rs1, rs2` 8 | 9 | - 把符号位扩展的立即数和寄存器x[rs1]上的值进行位与,结果写入 x[rd]。x[rd] = x[rs1] & sext(immediate): 10 | 11 | `andi rd, rs1, immediate` 12 | 13 | - 实例: 14 | 15 | `and t0,t1,t2` 16 | `and t0,t1,0b100` 17 | -------------------------------------------------------------------------------- /rv32i/auipc.md: -------------------------------------------------------------------------------- 1 | # auipc 2 | 3 | > PC加立即数. 4 | 5 | - 把符号位扩展的20 位(左移 12 位)立即数加到 pc上,结果写入 x[rd]。x[rd] = pc + sext(immediate[31:12] << 12): 6 | 7 | `auipc rd, immediate` 8 | 9 | 10 | - 实例: 11 | 12 | `auipc t0,0` 13 | 14 | -------------------------------------------------------------------------------- /rv32i/beq.md: -------------------------------------------------------------------------------- 1 | # beq 2 | 3 | > 相等时分支. 4 | 5 | - 若寄存器x[rs1]和寄存器x[rs2]的值相等,把pc的值设为当前值加上符号位扩展的偏移offset。if (rs1 == rs2) pc += sext(offset): 6 | 7 | `beq rs1, rs2, offset` 8 | 9 | - 实例: 10 | 11 | `beq t0,t1,lable` 12 | -------------------------------------------------------------------------------- /rv32i/bge.md: -------------------------------------------------------------------------------- 1 | # bge[u] 2 | 3 | > 大于等时分支. 4 | 5 | - 若寄存器 x[rs1]的值大于等于寄存器x[rs2]的值(均视为二进制补码),把 pc的值设为当前值加上符号位扩展的偏移 offset。if (rs1 ≥s rs2) pc += sext(offset): 6 | 7 | `bge rs1, rs2, offset` 8 | 9 | - 若寄存器x[rs1]的值大于等于寄存器 x[rs2]的值(均视为无符号数),把 pc的值设为当前值加上符号位扩展的偏移offset。if (rs1 ≥u rs2) pc += sext(offset): 10 | 11 | `bgeu rs1, rs2, offset` 12 | 13 | - 实例: 14 | 15 | `bge t0, t1, lable` 16 | `bgeu t0, t1, lable` 17 | -------------------------------------------------------------------------------- /rv32i/blt.md: -------------------------------------------------------------------------------- 1 | # blt 2 | 3 | > 小于时分支. 4 | 5 | - 若寄存器 x[rs1]的值小于寄存器x[rs2]的值(均视为二进制补码),把 pc的值设为当前值加上符号位扩展的偏移 offset。if (rs1 不相等时分支. 4 | 5 | - 若寄存器 x[rs1]和寄存器 x[rs2]的值不相等,把 pc的值设为当前值加上符号位扩展偏移offset。if (rs1 ≠ rs2) pc += sext(offset): 6 | 7 | `bne rs1, rs2, offset` 8 | 9 | - 实例: 10 | 11 | `bne t0, t1, lable` 12 | -------------------------------------------------------------------------------- /rv32i/csrrc.md: -------------------------------------------------------------------------------- 1 | # csrrc[i] 2 | 3 | > 读后清除控制状态寄存器 . 4 | 5 | - t = CSRs[csr]; CSRs[csr] = t &~x[rs1]; x[rd] = t: 6 | 7 | `csrrc rd, csr, rs1` 8 | 9 | - t = CSRs[csr]; CSRs[csr] = t &~zimm; x[rd] = t (csr寄存器的第5位及更高不变): 10 | 11 | `csrrci rd, csr, zimm[4:0]` 12 | 13 | - 实例: 14 | 15 | `csrrci t0, mie, t1` 16 | `csrrci t0, mie, 0b11010` 17 | -------------------------------------------------------------------------------- /rv32i/csrrs.md: -------------------------------------------------------------------------------- 1 | # csrrs[i] 2 | 3 | > 读后置位控制状态寄存器 . 4 | 5 | - t = CSRs[csr]; CSRs[csr] = t | x[rs1]; x[rd] = t: 6 | 7 | `csrrs rd, csr, rs1` 8 | 9 | - t = CSRs[csr]; CSRs[csr] = t | zimm; x[rd] = t(csr寄存器的第5位及更高不变): 10 | 11 | `csrrsi rd, csr, zimm[4:0]` 12 | 13 | - 实例: 14 | 15 | `csrrs t0, mie, t1` 16 | `csrrs t0, mie, 0b11010` 17 | -------------------------------------------------------------------------------- /rv32i/csrrw.md: -------------------------------------------------------------------------------- 1 | # csrrw[i] 2 | 3 | > 读后写控制状态寄存器 . 4 | 5 | - t = CSRs[csr]; CSRs[csr] = x[rs1]; x[rd] = t: 6 | 7 | `csrrw rd, csr, rs1` 8 | 9 | - x[rd] = CSRs[csr]; CSRs[csr] = zimm(只写五位的零扩展立即数): 10 | 11 | `csrrwi rd, csr, zimm[4:0]` 12 | 13 | - 实例: 14 | 15 | `csrrs t0, mie, t1` 16 | `csrrs t0, mie, 0b11010` 17 | -------------------------------------------------------------------------------- /rv32i/ebreak.md: -------------------------------------------------------------------------------- 1 | # ebreak 2 | 3 | > 环境断点. 4 | 5 | - 通过抛出断点异常的方式请求调试器: 6 | 7 | `ebreak` 8 | -------------------------------------------------------------------------------- /rv32i/ecall.md: -------------------------------------------------------------------------------- 1 | # ecall 2 | 3 | > 环境调用. 4 | 5 | - 通过引发环境调用异常来请求执行: 6 | 7 | `ecall` 8 | -------------------------------------------------------------------------------- /rv32i/fence.md: -------------------------------------------------------------------------------- 1 | # fence[.i] 2 | 3 | > 同步内存和I/O和指令流 4 | > fence在后续指令中的内存和I/O访问对外部(例如其他线程)可见之前,使这条指令的内存及I/O访问对外部可见。比特中的第 3,2,1和 0位分别对应于设备输入,输出,内存读,写。 5 | > fence.i 同步指令流 6 | 7 | - 对所有访存进行排序: 8 | 9 | `fence` 10 | `fence iorw, iorw` 11 | 12 | - 将前面读取与后面的读取和写入排序: 13 | 14 | `fence r, rw` 15 | 16 | - 使对内存指令区域的读写,对后续取指令可见。 17 | 18 | `fence.i` -------------------------------------------------------------------------------- /rv32i/jal.md: -------------------------------------------------------------------------------- 1 | # jal 2 | 3 | > 跳转并链接. 4 | 5 | - 把下一条指令的地址(pc+4)放入寄存器ra,然后把 pc设置为当前值加上符号位扩展的的 offset。rd默认为 x1(ra)。x[rd] = pc+4; pc += sext(offset): 6 | 7 | `jal rd, offset` 8 | 9 | - 实例: 10 | 11 | `jal ra,func` 12 | 13 | -------------------------------------------------------------------------------- /rv32i/jalr.md: -------------------------------------------------------------------------------- 1 | # jalr 2 | 3 | > 跳转并寄存器链接. 4 | 5 | - 把pc设置为 x[rs1] + sign-extend(offset),把计算出的地址最低有效位设为 0,并将原 pc+4的值写入 f[rd], rd默认为 x1。t =pc+4; pc=(x[rs1]+sext(offset))&~1; x[rd]=t: 6 | 7 | `jalr rd, offset(rs1)` 8 | 9 | - 实例: 10 | 11 | `jalr ra, offset(t0)` 12 | 13 | -------------------------------------------------------------------------------- /rv32i/lb.md: -------------------------------------------------------------------------------- 1 | # lb[u] 2 | 3 | > 字节加载. 4 | 5 | - 从地址x[rs1] + sign-extend(offset)读取一个字节,经符号位扩展后写入 x[rd]。x[rd] = sext(M[x[rs1] + sext(offset)][7:0]): 6 | 7 | `lb rd, offset(rs1)` 8 | 9 | - 从地址x[rs1] + sign-extend(offset)读取一个字节,经零扩展后写入 x[rd]。x[rd] = M[x[rs1] + sext(offset)][7:0]: 10 | 11 | `lbu rd, offset(rs1)` 12 | 13 | - 实例: 14 | 15 | `lb t0, 3(a0)` 16 | `lbu t0, 3(a0)` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/ld.md: -------------------------------------------------------------------------------- 1 | # ld 2 | 3 | > 双字加载. 4 | 5 | - 从地址x[rs1] + sign-extend(offset)读取八个字节,写入 x[rd]。x[rd] = M[x[rs1] + sext(offset)][63:0]: 6 | 7 | `ld rd, offset(rs1)` 8 | 9 | -------------------------------------------------------------------------------- /rv32i/lh.md: -------------------------------------------------------------------------------- 1 | # lh[u] 2 | 3 | > 半字加载. 4 | 5 | - 从地址x[rs1] + sign-extend(offset)读取两个字节,经符号位扩展后写入 x[rd]。x[rd] = sext(M[x[rs1] + sext(offset)][15:0]): 6 | 7 | `lh rd, offset(rs1)` 8 | 9 | - 从地址x[rs1] + sign-extend(offset)读取两个字节,经零扩展后写入 x[rd]。x[rd] = M[x[rs1] + sext(offset)][15:0]: 10 | 11 | `lhu rd, offset(rs1)` 12 | 13 | - 实例: 14 | 15 | `lh t0, 2(a0)` 16 | `lhu t0, 2(a0)` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/lui.md: -------------------------------------------------------------------------------- 1 | # lui 2 | 3 | > 高位立即数加载. 4 | 5 | - 将符号位扩展的20位立即数immediate左移12位,并将低12位置零,写入 x[rd]中。x[rd] = sext(immediate[31:12] << 12): 6 | 7 | `lui rd, immediate` 8 | 9 | -------------------------------------------------------------------------------- /rv32i/lw.md: -------------------------------------------------------------------------------- 1 | # lw[u] 2 | 3 | > 字加载. 4 | 5 | - 从地址x[rs1] + sign-extend(offset)读取四个字节,写入 x[rd](RV64I 经符号位扩展)。x[rd] = sext(M[x[rs1] + sext(offset)][31:0]): 6 | 7 | `lw rd, offset(rs1)` 8 | 9 | - 从地址x[rs1] + sign-extend(offset)读取四个字节,写入 x[rd](RV64I 经零扩展后)。x[rd] = M[x[rs1] + sext(offset)][31:0]: 10 | 11 | `lwu rd, offset(rs1)` 12 | 13 | - 实例: 14 | 15 | `lw t0, 4(a0)` 16 | `lwu t0, 4(a0)` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/mret.md: -------------------------------------------------------------------------------- 1 | # mret 2 | 3 | > 机器模式异常返回. 4 | 5 | - 从机器模式异常处理程序返回。将 pc设置为CSRs[mepc], 将特权级设置成 CSRs[mstatus].MPP, CSRs[mstatus].MIE置成 CSRs[mstatus].MPIE, 并且将CSRs[mstatus].MPIE为 1; 如果支持用户模式则将 CSR [mstatus].MPP设置为 设置为 0: 6 | 7 | `mret` 8 | 9 | -------------------------------------------------------------------------------- /rv32i/or.md: -------------------------------------------------------------------------------- 1 | # or 2 | 3 | > 取或. 4 | 5 | - 把寄存器 x[rs1]和寄存器x[rs2]按位取或,结果写入x[rd], x[rd]=x[rs1] | x[rs2]: 6 | 7 | `or rd, rs1, rs2` 8 | 9 | - 把寄存器 x[rs1]和有符号扩展的立即数immediate(只有低12bit有效)按位取或,结果写 入 x[rd]。x[rd]=x[rs1] | sext(immediate): 10 | 11 | `ori rd, rs1, immediate` 12 | 13 | - 实例: 14 | 15 | `or a0, t1, t2` 16 | `ori a0, t1, 0b11011` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/sb.md: -------------------------------------------------------------------------------- 1 | # sb 2 | 3 | > 存字节. 4 | 5 | - 将 x[rs2]的低位字节存入内地址x[rs1]+sign-extend(offset)。M[x[rs1]+sext(offset)=x[rs2][7:0]: 6 | 7 | `sb rs2, offset(rs1)` 8 | 9 | - 实例: 10 | 11 | `sb t0, 3(a0)` 12 | 13 | -------------------------------------------------------------------------------- /rv32i/sh.md: -------------------------------------------------------------------------------- 1 | # lh 2 | 3 | > 存半字. 4 | 5 | - 将 x[rs2]的低位2字节存入内地址x[rs1]+sign-extend(offset)。M[x[rs1]+sext(offset)=x[rs2][15:0]: 6 | 7 | `sh rs2, offset(rs1)` 8 | 9 | - 实例: 10 | 11 | `sh t0, 3(a0)` 12 | 13 | -------------------------------------------------------------------------------- /rv32i/sll.md: -------------------------------------------------------------------------------- 1 | # sll 2 | 3 | > 逻辑左移. 4 | 5 | - rs2低5位为左移位数,高位忽略。左移后空出位数补0。x[rd]=x[rs1] << x[rs2]: 6 | 7 | `sll rd, rs1, rs2` 8 | 9 | - 立即数shamt低5位为左移位数,第6位必须为0,左移后空出位数补0。x[rd]=x[rs1] << shamt 10 | 11 | `slli rd, rs1, shamt` 12 | 13 | - 实例: 14 | 15 | `sll t0, t0, t1` 16 | `slli t0, t0, 3` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/slt.md: -------------------------------------------------------------------------------- 1 | # slt[i][u] 2 | 3 | > 小于则置位. 4 | 5 | - 比较 x[rs1]和 x[rs2]中的数,如果 x[rs1]更小,向 x[rd]写入 1,否则写入 0。x[rd]=(x[rs1] 算数右移. 4 | 5 | - rs2低5位为右移位数,高位忽略。右移后空出位数用x[rs1]的最高位填充。x[rd]=(x[rs1]>>s x[rs2]): 6 | 7 | `sra rd, rs1, rs2` 8 | 9 | - 立即数shamt低5位为→移位数,第6位必须为0,右移后空出位数用x[rs1]的最高位填充。x[rd]=x[rs1] >>s shamt 10 | 11 | `srai rd, rs1, shamt` 12 | 13 | - 实例: 14 | 15 | `sll t0, t0, t1` 16 | `slli t0, t0, 3` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/sret.md: -------------------------------------------------------------------------------- 1 | # sret 2 | 3 | > 管理员模式例外返回. 4 | 5 | - 从管理员模式的例外处程序中返回。将 pc设置为CSRs[sepc], 将特权级设置成 CSRs[sstatus].SPP, CSRs[sstatus].SIE置成 CSRs[sstatus].SPIE, 并且将CSRs[sstatus].SPIE为 1; 如果支持用户模式则将 CSR [sstatus].SPP设置为 设置为 0: 6 | 7 | `sret` 8 | 9 | -------------------------------------------------------------------------------- /rv32i/srl.md: -------------------------------------------------------------------------------- 1 | # srl 2 | 3 | > 逻辑右移. 4 | 5 | - rs2低5位为右移位数,高位忽略。右移后空出位数补0。x[rd]=x[rs1] >>u x[rs2]: 6 | 7 | `sll rd, rs1, rs2` 8 | 9 | - 立即数shamt低5位为右移位数,第6位必须为0,右移后空出位数补0。x[rd]=x[rs1] >>u shamt 10 | 11 | `srli rd, rs1, shamt` 12 | 13 | - 实例: 14 | 15 | `sll t0, t0, t1` 16 | `slli t0, t0, 3` 17 | 18 | -------------------------------------------------------------------------------- /rv32i/sub.md: -------------------------------------------------------------------------------- 1 | # sub 2 | 3 | > 减法. 4 | 5 | - 忽略算术溢出。x[rd]=x[rs1] - x[rs2]: 6 | 7 | `sub rd, rs1, rs2` 8 | 9 | - 实例: 10 | 11 | `sub t0,t1,t2` 12 | -------------------------------------------------------------------------------- /rv32i/sw.md: -------------------------------------------------------------------------------- 1 | # lw 2 | 3 | > 存字. 4 | 5 | - 将 x[rs2]的低位4字节存入内地址x[rs1]+sign-extend(offset)。M[x[rs1]+sext(offset)=x[rs2][31:0]: 6 | 7 | `sw rs2, offset(rs1)` 8 | 9 | - 实例: 10 | 11 | `sw t0, 4(a0)` 12 | 13 | -------------------------------------------------------------------------------- /rv32i/wfi.md: -------------------------------------------------------------------------------- 1 | # wfi 2 | 3 | > 等待中断. 4 | 5 | - 如果没有待处理的中断,则使器于空闲状态(进入省电模式): 6 | 7 | `wfi` 8 | 9 | -------------------------------------------------------------------------------- /rv32i/xor.md: -------------------------------------------------------------------------------- 1 | # xor 2 | 3 | > 取或. 4 | 5 | - 把寄存器 x[rs1]和寄存器x[rs2]按位取异或,结果写入x[rd], x[rd]=x[rs1] ^ x[rs2]: 6 | 7 | `xor rd, rs1, rs2` 8 | 9 | - 把寄存器 x[rs1]和有符号扩展的立即数immediate(只有低12bit有效)按位取异或,结果写 入 x[rd]。x[rd]=x[rs1] …… sext(immediate): 10 | 11 | `xori rd, rs1, immediate` 12 | 13 | - 实例: 14 | 15 | `xor a0, t1, t2` 16 | `xori a0, t1, 0b11011` 17 | 18 | --------------------------------------------------------------------------------