Skip to content

Commit

Permalink
doc: Update docs with some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Granddave committed Jan 22, 2024
1 parent ef0075a commit a75d4e6
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,43 @@
///
/// For example, `LDA #$C8` is represented as:
///
/// ```text
/// Instruction::new(
/// ```
/// # use mos6502::ast::{Instruction, Mnemonic, AddressingMode, Operand};
/// let instruction = Instruction::new(
/// Mnemonic::LDA,
/// AddressingMode::Immediate,
/// Operand::Immediate(0xC8),
/// ),
/// );
/// ```
pub mod ast;

/// Transforms 6502 assembly code to machine code.
///
/// The steps are:
/// 1. **[Lexing][assembler::lexer::Lexer]** - converting a string into tokens
/// 2. **[Parsing][assembler::parser::Parser]** - converting tokens into an AST
/// 3. **[Compiling][assembler::codegen::Generator]** - converting an AST into machine code in multiple passes
/// - Pass 1: Symbol resolution - resolving labels
/// - Pass 2: Code generation - generating machine code
/// 3. **[Symbol resolution][assembler::symbols]** - resolving symbols like constants and labels in the AST
/// 4. **[Code generator][assembler::codegen]** - converting an AST into machine code
pub mod assembler;

/// Transforms machine code to assembly code.
/// Transforms machine code to its AST (Abstract Syntax Tree) representation.
///
/// Usage:
/// ```
/// use mos6502::{
/// ast::{AddressingMode, Instruction, Mnemonic, Operand},
/// disassembler::disassemble_code,
/// };
///
/// assert_eq!(
/// disassemble_code(&[0xA9, 0xC8]),
/// vec![Instruction::new(
/// Mnemonic::LDA,
/// AddressingMode::Immediate,
/// Operand::Immediate(0xC8)
/// )]
/// );
/// ```
pub mod disassembler;

/// 6502 CPU emulator
Expand Down

0 comments on commit a75d4e6

Please sign in to comment.