diff --git a/dcb-exe/src/exe/inst.rs b/dcb-exe/src/exe/inst.rs index b4579b7..2d0d5a1 100644 --- a/dcb-exe/src/exe/inst.rs +++ b/dcb-exe/src/exe/inst.rs @@ -1,24 +1,40 @@ //! Psx cpu instructions +//! +//! This module defines all instructions for the psx cpu, the +//! `MIPS R3051`, following [Nocash's specifications](https://problemkaputt.de/psx-spx.htm). +//! +//! The instructions are split across 3 main types, +//! - `[basic::Inst]`, which defines all 'basic' instructions, i.e. all instructions which are +//! a single word in size and that carry no simplifications (such as `addi $a0, $a0, 10` == `addi $a0, 10`). +//! - `[pseudo::Inst]`, instructions which are decoded from basic instructions and that represent either +//! a simplified version of an instruction, or multiple instructions (such as `la $a0, 0x80001000` == `lui $a0, 0x8000 / addiu $ao, 0x1000`). +//! - `[Directive]`, which represent data, rather than instructions, such as `dw` and `.ascii`. +//! +//! See each instruction's module for information on how they are decoded and their variants. +//! +//! Every instruction also uses the [`Register`] enum, which defines all registers in the cpu (except instruction specific +//! registers, such as the `lo` and `hi` registers). +//! +//! This module also contains the [`iter`] module, home to the [`ParseIter`] type, an iterator which parses +//! instructions from raw bytes and their position in memory. // Modules pub mod basic; pub mod directive; pub mod iter; pub mod pseudo; -pub mod raw; pub mod reg; // Exports pub use directive::Directive; pub use iter::ParseIter; -pub use raw::Raw; pub use reg::Register; // Imports use crate::Pos; use std::fmt; -/// An assembler instruction +/// An assembler instruction. #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum Inst { /// A basic instruction @@ -59,6 +75,11 @@ impl InstFmt for Inst { } /// A formattable basic instruction +/// +/// This trait defines formatting for all instruction, which may require the +/// instruction's current position (for relative instructions, such as the +/// branching instructions), as well as the byte array containing the entire +/// executable. pub trait InstFmt { /// Returns this instruction's mnemonic fn mnemonic(&self) -> &'static str;