rabbitizer/README.md

149 lines
6.3 KiB
Markdown
Raw Normal View History

2022-06-03 17:46:51 +00:00
# rabbitizer
2022-06-23 04:29:41 +00:00
[![PyPI - Downloads](https://img.shields.io/pypi/dm/rabbitizer)](https://pypi.org/project/rabbitizer/)
![GitHub](https://img.shields.io/github/license/Decompollaborate/rabbitizer)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/Decompollaborate/rabbitizer)
![PyPI](https://img.shields.io/pypi/v/rabbitizer)
2022-12-18 21:37:07 +00:00
![crate.io](https://img.shields.io/crates/dv/rabbitizer)
2022-06-23 04:29:41 +00:00
![GitHub contributors](https://img.shields.io/github/contributors/Decompollaborate/rabbitizer?logo=purple)
2022-12-24 00:41:45 +00:00
MIPS instruction decoder API.
2022-06-23 04:29:41 +00:00
2022-12-24 00:41:45 +00:00
## Features
- Should produce matching assembly.
- Fully written in C for fast decoding.
2022-12-24 02:21:54 +00:00
- The library is completely allocation-less, in other words `rabbitizer`
doesn't allocate in anything in the heap by itself.
2022-12-24 00:41:45 +00:00
- Other language bindings supported in this repo:
- Python bindings
2024-04-23 15:09:58 +00:00
- The minimal Python version is 3.7, older versions are not guaranteed to
work.
2022-12-24 00:41:45 +00:00
- C++ bindings
- Rust bindings
- Simple per-word instruction decoding.
2022-12-24 02:21:54 +00:00
- The library doesn't try to be too smart by processing multiple instructions
2024-04-23 15:09:58 +00:00
at a time.
2022-12-24 00:41:45 +00:00
- Can perform validation checks for instructions.
2022-12-24 02:21:54 +00:00
- Provides many examination/grouping functions for instructions, allowing to
simplify checking characteristics of an instruction and minimizing the need to
check for specific instructions in a hardcoded way.
2022-12-24 00:41:45 +00:00
- Includes some minor tools to build your own pointer/symbol detection.
- Configurable, many features can be turned on and off.
- MIPS instructions features:
2024-04-23 15:09:58 +00:00
- Configurable behavior for the `jalr` instruction, allowing to disassemble
that instruction using an implicit or explicit `rd` register depending if
that register is `$ra` or not.
2022-12-24 00:41:45 +00:00
- Named registers for MIPS VR4300's coprocessors.
- Support for many pseudo-instructions.
- Properly handle move to/from coprocessor instructions.
- Support for numeric, o32, n32 and n64 ABI register names.
- Some workarounds for some specific compilers/assemblers:
- `SN64`:
- `div`/`divu` fix: tweaks a bit the produced `div`, `divu` and `break` instructions.
- Multiple MIPS architectures are supported:
- Main focus on MIPS I, II and III architectures. Partial support for MIPS IV too.
- N64 RSP instruction decoding support.
- RSP decoding has been tested to build back to matching assemblies with [armips](https://github.com/Kingcom/armips/).
ALLEGREX support (#60) * setup ALLEGREX * more setup * clo * fix * Implement SPECIAL_RS and SPECIAL_SA instructions * more table placeholders * Implement bshfl instructions * Rename to R4000Allegrex * Implement SPECIAL instructions * Add tests * Remove some duplicated tests * Implement SPECIAL3 instructions * fix bug in test * update * Implement COPz * Implement SPECIAL2 instructions * Implement COP1 * Yeet cop3 * som tests * bvf, bvfl, bvt, bvtl * fix bshfl prefix * need to implement the vfpu registers * implement vt_7? * R4000AllegrexVF -> R4000AllegrexVScalar * Add test suite to compare with the sn toolchain decoding * more vfpu test cases * forgor this * I can't decide how to name these registers * Prepare tables for all register types * Fix typo * Implement vector scalar register operands * Implement quad registers * Fix tests? * svl.q, svr.q * Implement a bunch of vfpu0 instructions * implement registers for `.t` and `.p` instructions * Implement VFPU1 instructions * bleh * VFPU1, VFPU3 and `vcmp.` * Fix wrong register type on some instructions * start vfpu3 * Implement VFPU3 instructions * start categorizing VFPU4 * Categorize VFPU5 * VFPU6 identification * Identify VFPU7 * COP2 is weird * organize COP2 a bit * Add test cases for VFPU4 FMT * VFPU4 FMT2 stuff * VFPU4 FMT3 stuff * VFPU5 stuff * VFPU6 stuff * VFPU7 stuff * Implement COP2 instructions * Implement vmov, vabs and vneg * VPFU4 FMT0 FMT0 FMT0 implemented * VFPU FMT0 FMT0 FMT2 * vnrcp, vnsin, vrexp2 * vrnds, vrndi, vrndf1, vrndf2 * Change tests a bit * vf2h, vh2f, vsbz, vlgb * vuc2ifs, vc2i, vus2i, vs2i, vi2uc, vi2c, vi2us, vi2s * vsrt1, vsrt2, vbfy1, vbfy2, vocp, vsocp, vfad, vavg * vsrt3, vsrt4, vsgn * vmfvc and vmtvc placeholders * vt4444, vt5551, vt5650 * vcst placeholder * vf2in * vf2iz * vf2iu, vf2id, vi2f * vcmovt, vcmovf * vwbn.s, viim.s, vfim.s * vpfxs, vpfxt, vpfxd, vnop, vsync, vflush * vmmov, vmidt, vmzero, vmone * vrot * vmmul, vhtfm2, vtfm2, vhtfm3, vtfm3, vhtfm4, vtfm4, vmscl, vcrsp, vqmul * Implement matrix operands * fix matrix operands * Fix `illegal` tests * hack out a way to check the test cases are assemblable * test-fixing: branches * fix more test cases * fix vmfvc and vmtvc * more test fixing * vdiv and fix operand R323 * more test fixing * Fix matrix operands * implement vcmp comparisons * fix vsync2 * vsqrt and vrndf1 fixes * Implement "constant" operand for `vcst` * Add missing operand of vf2in, vf2iz, vf2iu, vf2id, vi2f * Add missing vcmovt and vcmovf operands * Add missing vwbn operand * Tests cases for vmmul * Fix vtfm2 * Implement "transpose matrix register" * Add placeholders for the remaining missing operands * Implement viim operand * Implement vrot code operand * placeholders for rp and wp operands * test cases for vpfxs, vpfxt and vpfxd * Properly implement rpx, rpy, rpz and rpw * Properly implement wpx, wpy, wpz and wpw operands * Implement vfim * changelog * readme * some cleanup * Restructure some tables * more table restructure * fix tests * more table yeeting * more cleanup * more cleanup * reanming * moar * fmt
2024-04-22 17:15:58 +00:00
- R3000 GTE (PSX's CPU) decoding support.
- R4000 ALLEGREX (PSP's CPU) decoding support.
2022-12-24 00:41:45 +00:00
- R5900 (PS2's Emotion Engine processor) decoding support.
## Non-features
In order to keep it simple and fast the following features will not be added:
- Pseudo-instructions which expands to more than one instruction.
2022-06-23 04:29:41 +00:00
## Installing
2022-12-18 21:37:07 +00:00
### Python bindings
2022-06-23 04:29:41 +00:00
The recommended way to install is using from the PyPi release, via `pip`:
```bash
2024-03-18 13:16:51 +00:00
python3 -m pip install -U rabbitizer
2022-06-23 04:29:41 +00:00
```
2024-03-18 13:16:51 +00:00
If you use a `requirements.txt` file in your repository, then you can add this
library with the following line:
```txt
2024-12-16 11:44:20 +00:00
rabbitizer>=1.12.3,<2.0.0
2024-03-18 13:16:51 +00:00
```
### Development version
The unstable development version is located at the
[develop](https://github.com/Decompollaborate/rabbitizer/tree/develop)
branch. PRs should be made into that branch instead of the main one.
ALLEGREX support (#60) * setup ALLEGREX * more setup * clo * fix * Implement SPECIAL_RS and SPECIAL_SA instructions * more table placeholders * Implement bshfl instructions * Rename to R4000Allegrex * Implement SPECIAL instructions * Add tests * Remove some duplicated tests * Implement SPECIAL3 instructions * fix bug in test * update * Implement COPz * Implement SPECIAL2 instructions * Implement COP1 * Yeet cop3 * som tests * bvf, bvfl, bvt, bvtl * fix bshfl prefix * need to implement the vfpu registers * implement vt_7? * R4000AllegrexVF -> R4000AllegrexVScalar * Add test suite to compare with the sn toolchain decoding * more vfpu test cases * forgor this * I can't decide how to name these registers * Prepare tables for all register types * Fix typo * Implement vector scalar register operands * Implement quad registers * Fix tests? * svl.q, svr.q * Implement a bunch of vfpu0 instructions * implement registers for `.t` and `.p` instructions * Implement VFPU1 instructions * bleh * VFPU1, VFPU3 and `vcmp.` * Fix wrong register type on some instructions * start vfpu3 * Implement VFPU3 instructions * start categorizing VFPU4 * Categorize VFPU5 * VFPU6 identification * Identify VFPU7 * COP2 is weird * organize COP2 a bit * Add test cases for VFPU4 FMT * VFPU4 FMT2 stuff * VFPU4 FMT3 stuff * VFPU5 stuff * VFPU6 stuff * VFPU7 stuff * Implement COP2 instructions * Implement vmov, vabs and vneg * VPFU4 FMT0 FMT0 FMT0 implemented * VFPU FMT0 FMT0 FMT2 * vnrcp, vnsin, vrexp2 * vrnds, vrndi, vrndf1, vrndf2 * Change tests a bit * vf2h, vh2f, vsbz, vlgb * vuc2ifs, vc2i, vus2i, vs2i, vi2uc, vi2c, vi2us, vi2s * vsrt1, vsrt2, vbfy1, vbfy2, vocp, vsocp, vfad, vavg * vsrt3, vsrt4, vsgn * vmfvc and vmtvc placeholders * vt4444, vt5551, vt5650 * vcst placeholder * vf2in * vf2iz * vf2iu, vf2id, vi2f * vcmovt, vcmovf * vwbn.s, viim.s, vfim.s * vpfxs, vpfxt, vpfxd, vnop, vsync, vflush * vmmov, vmidt, vmzero, vmone * vrot * vmmul, vhtfm2, vtfm2, vhtfm3, vtfm3, vhtfm4, vtfm4, vmscl, vcrsp, vqmul * Implement matrix operands * fix matrix operands * Fix `illegal` tests * hack out a way to check the test cases are assemblable * test-fixing: branches * fix more test cases * fix vmfvc and vmtvc * more test fixing * vdiv and fix operand R323 * more test fixing * Fix matrix operands * implement vcmp comparisons * fix vsync2 * vsqrt and vrndf1 fixes * Implement "constant" operand for `vcst` * Add missing operand of vf2in, vf2iz, vf2iu, vf2id, vi2f * Add missing vcmovt and vcmovf operands * Add missing vwbn operand * Tests cases for vmmul * Fix vtfm2 * Implement "transpose matrix register" * Add placeholders for the remaining missing operands * Implement viim operand * Implement vrot code operand * placeholders for rp and wp operands * test cases for vpfxs, vpfxt and vpfxd * Properly implement rpx, rpy, rpz and rpw * Properly implement wpx, wpy, wpz and wpw operands * Implement vfim * changelog * readme * some cleanup * Restructure some tables * more table restructure * fix tests * more table yeeting * more cleanup * more cleanup * reanming * moar * fmt
2024-04-22 17:15:58 +00:00
Note that building the Python bindings from source require the Python
development package. Under Ubuntu/Debian based distros it can be installed with:
```bash
apt install python3-dev
```
2022-12-24 02:21:54 +00:00
In case you want to mess with the latest development version without wanting to
clone the repository, then you could use the following command:
2022-06-23 04:29:41 +00:00
```bash
2024-03-18 13:16:51 +00:00
python3 -m pip uninstall rabbitizer
python3 -m pip install git+https://github.com/Decompollaborate/rabbitizer.git@develop
2022-06-23 04:29:41 +00:00
```
2022-12-24 02:21:54 +00:00
NOTE: Installing the development version is not recommended. Proceed at your own
risk.
2022-06-23 04:29:41 +00:00
2022-12-18 21:37:07 +00:00
See this package at <https://pypi.org/project/rabbitizer/>.
### Rust bindings
2023-11-12 15:26:37 +00:00
Add this crate to your project with Cargo:
```bash
cargo add rabbitizer
```
Or you can add it manually to your `Cargo.toml`:
2022-12-18 21:37:07 +00:00
```toml
2024-12-16 11:44:20 +00:00
rabbitizer = "1.12.3"
2022-12-18 21:37:07 +00:00
```
See this crate at <https://crates.io/crates/rabbitizer>.
## References
2022-12-14 18:27:16 +00:00
- MIPS CPU:
- MIPS IV Instruction Set (Revision 3.2): <https://www.cs.cmu.edu/afs/cs/academic/class/15740-f97/public/doc/mips-isa.pdf>
- MIPS Calling Convention Summary: <https://courses.cs.washington.edu/courses/cse410/09sp/examples/MIPSCallingConventionsSummary.pdf>
- mipt-mips pseudo instructions: <https://github.com/MIPT-ILab/mipt-mips/wiki/MIPS-pseudo-instructions>
2024-07-13 21:30:13 +00:00
- IDT R30xx Family Software Reference Manual, page 325 (for `rfe`): <https://psx.arthus.net/docs/R3000.pdf>
2022-12-14 18:27:16 +00:00
- N64's RSP (Reality Signal Processor):
- Nintendo Ultra64 RSP Programmers Guide: <https://ultra64.ca/files/documentation/silicon-graphics/SGI_Nintendo_64_RSP_Programmers_Guide.pdf>
- N64brew Reality Signal Processor/CPU Core: <https://n64brew.dev/wiki/Reality_Signal_Processor/CPU_Core>
- R3000 GTE:
- PSYQ SDK headers: <https://github.com/FoxdieTeam/psyq_sdk/blob/master/psyq_4.4/INCLUDE/INLINE_A.H>
- no$psx documentation: <https://problemkaputt.de/psxspx-gte-opcode-summary.htm>
- no$psx documentation: <http://problemkaputt.de/psx-spx.htm#geometrytransformationenginegte>
- <http://www.raphnet.net/electronique/psx_adaptor/Playstation.txt>
ALLEGREX support (#60) * setup ALLEGREX * more setup * clo * fix * Implement SPECIAL_RS and SPECIAL_SA instructions * more table placeholders * Implement bshfl instructions * Rename to R4000Allegrex * Implement SPECIAL instructions * Add tests * Remove some duplicated tests * Implement SPECIAL3 instructions * fix bug in test * update * Implement COPz * Implement SPECIAL2 instructions * Implement COP1 * Yeet cop3 * som tests * bvf, bvfl, bvt, bvtl * fix bshfl prefix * need to implement the vfpu registers * implement vt_7? * R4000AllegrexVF -> R4000AllegrexVScalar * Add test suite to compare with the sn toolchain decoding * more vfpu test cases * forgor this * I can't decide how to name these registers * Prepare tables for all register types * Fix typo * Implement vector scalar register operands * Implement quad registers * Fix tests? * svl.q, svr.q * Implement a bunch of vfpu0 instructions * implement registers for `.t` and `.p` instructions * Implement VFPU1 instructions * bleh * VFPU1, VFPU3 and `vcmp.` * Fix wrong register type on some instructions * start vfpu3 * Implement VFPU3 instructions * start categorizing VFPU4 * Categorize VFPU5 * VFPU6 identification * Identify VFPU7 * COP2 is weird * organize COP2 a bit * Add test cases for VFPU4 FMT * VFPU4 FMT2 stuff * VFPU4 FMT3 stuff * VFPU5 stuff * VFPU6 stuff * VFPU7 stuff * Implement COP2 instructions * Implement vmov, vabs and vneg * VPFU4 FMT0 FMT0 FMT0 implemented * VFPU FMT0 FMT0 FMT2 * vnrcp, vnsin, vrexp2 * vrnds, vrndi, vrndf1, vrndf2 * Change tests a bit * vf2h, vh2f, vsbz, vlgb * vuc2ifs, vc2i, vus2i, vs2i, vi2uc, vi2c, vi2us, vi2s * vsrt1, vsrt2, vbfy1, vbfy2, vocp, vsocp, vfad, vavg * vsrt3, vsrt4, vsgn * vmfvc and vmtvc placeholders * vt4444, vt5551, vt5650 * vcst placeholder * vf2in * vf2iz * vf2iu, vf2id, vi2f * vcmovt, vcmovf * vwbn.s, viim.s, vfim.s * vpfxs, vpfxt, vpfxd, vnop, vsync, vflush * vmmov, vmidt, vmzero, vmone * vrot * vmmul, vhtfm2, vtfm2, vhtfm3, vtfm3, vhtfm4, vtfm4, vmscl, vcrsp, vqmul * Implement matrix operands * fix matrix operands * Fix `illegal` tests * hack out a way to check the test cases are assemblable * test-fixing: branches * fix more test cases * fix vmfvc and vmtvc * more test fixing * vdiv and fix operand R323 * more test fixing * Fix matrix operands * implement vcmp comparisons * fix vsync2 * vsqrt and vrndf1 fixes * Implement "constant" operand for `vcst` * Add missing operand of vf2in, vf2iz, vf2iu, vf2id, vi2f * Add missing vcmovt and vcmovf operands * Add missing vwbn operand * Tests cases for vmmul * Fix vtfm2 * Implement "transpose matrix register" * Add placeholders for the remaining missing operands * Implement viim operand * Implement vrot code operand * placeholders for rp and wp operands * test cases for vpfxs, vpfxt and vpfxd * Properly implement rpx, rpy, rpz and rpw * Properly implement wpx, wpy, wpz and wpw operands * Implement vfim * changelog * readme * some cleanup * Restructure some tables * more table restructure * fix tests * more table yeeting * more cleanup * more cleanup * reanming * moar * fmt
2024-04-22 17:15:58 +00:00
- R4000 ALLEGREX:
- ALLEGREX-Instruction_Manual-English <https://github.com/Decompollaborate/rabbitizer/files/11356332/ALLEGREX-Instruction_Manual-English.pdf>
- FPU-Instruction_Manual-English <https://github.com/Decompollaborate/rabbitizer/files/14950191/FPU-Instruction_Manual-English.pdf>
- VFPU-Instruction_Manual-English <https://github.com/Decompollaborate/rabbitizer/files/11356335/VFPU-Instruction_Manual-English.pdf>
- VFPU-Users_Manual-English <https://github.com/Decompollaborate/rabbitizer/files/11356333/VFPU-Users_Manual-English.pdf>
- yet another PlayStationPortable Documentation <http://hitmen.c02.at/files/yapspd/psp_doc/frames.html>
- Chapter "4.8 Allegrex Instructions" <http://hitmen.c02.at/files/yapspd/psp_doc/chap4.html#sec4.8>
- GNU binutils: <https://github.com/bminor/binutils-gdb/compare/011365b...a0176d8>
- R5900:
- EmotionEngine instruction decoding: <https://psi-rockin.github.io/ps2tek/#eeinstructiondecoding>
- Official documentation from Toshiba: <https://wiki.qemu.org/images/2/2a/C790.pdf>
- VU instruction manual: <http://lukasz.dk/files/vu-instruction-manual.pdf>
- GNU binutils: <https://github.com/bminor/binutils-gdb/blob/master/opcodes/mips-opc.c>