# guillex7/asm2010 architecture

> Architecture diagram of the GitHub repository guillex7/asm2010, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/guillex7/asm2010
- Repository: https://github.com/guillex7/asm2010

## Overview

##### Main Components
- Assembler Component: This includes modules responsible for parsing assembly code. Look into the directories “src/as_parse” (with source files for parsing and disassembling) and “src/parse.c/h” to represent where source code is converted from assembly language into an internal representation.
- Emulator Component: This covers the execution/emulation of the CS instruction set. The “src/m2010” directory has clearly separated submodules for CS, CS2010, and CS3. These subdirectories contain code for opcodes, platforms, registers, and specific machine instructions, which illustrate the architecture-specific emulation logic.
- Shared Utilities and Infrastructure: Files such as “src/hash_table.c/.h”, “src/trace_log.c/.h”, and “src/utils.h” serve as supporting libraries. They indicate common data structures, debugging/tracing, and general-purpose functions used across both the assembler and emulator.

##### Relationships and Interactions
- Data Flow: Start with input assembly programs (as seen in the “examples/asm” directories). These inputs are processed by the assembler, which calls parsing routines (src/as_parse and related files). The output from the assembler (likely in the form of intermediate representations or binaries) is then processed by the emulator modules in “src/m2010”. Emulation involves executing instructions based on opcodes and handling registers/memory.

##### Architectural Patterns
- Separation of Concerns: Clearly split the assembler (code parsing and assembly validation) from the emulator (instruction execution and state simulation).
- Modularity: Inside the m2010 folder, the project splits support for CS2010 and CS3. This modular design can be depicted as separate submodules that share common interfaces (e.g., common opcode handling and instruction dispatch).
- Cross-Platform Build/Configuration: With CMake and platform-specific configuration files (e.g., cmake/Platform/WASI.cmake), emphasize the abstract platform layer that allows the native library to be compiled for many targets.

##### Relevant Technologies and Frameworks
- Programming Language: C99 standard.
- Build Systems: CMake (and planned Meson support).
- Concepts: Emulation techniques, assembly parsing, modular opcode implementation, and platform abstraction.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Processing
    subgraph "Core Processing"
        Input["Assembly Input (Examples)"]:::input
        subgraph "Assembler/Parser Module"
            A1["Parser Directory"]:::core
            A2["Parser Files"]:::core
            A1 --> A2
        end
        subgraph "Emulator Module"
            E1["CS Emulator Core"]:::core
            E2["CS2010 Module"]:::core
            E3["CS3 Module"]:::core
            E1 --> E2
            E1 --> E3
        end
        Input --> A1
        A1 --> E1
    end

    %% Shared Utilities
    subgraph "Shared Utilities"
        HT["Hash Table Library"]:::utility
        TL["Trace Log Library"]:::utility
        UT["Utility Functions"]:::utility
    end

    %% Build & Configuration
    subgraph "Build & Configuration"
        B1["CMakeLists.txt"]:::build
        B2["cmake Directory"]:::build
    end

    %% Inter-module Dependencies
    A2 --> UT
    E1 --> UT
    B1 --> A1
    B1 --> E1

    %% Styles
    classDef input fill:#EEDDFE,stroke:#333,stroke-width:2px;
    classDef core fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef utility fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef build fill:#F9E79F,stroke:#333,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/guillex7/asm2010/tree/master/src/as_parse"
    click A2 "https://github.com/guillex7/asm2010/blob/master/src/parse.c"
    click E1 "https://github.com/guillex7/asm2010/tree/master/src/m2010"
    click E2 "https://github.com/guillex7/asm2010/tree/master/src/m2010/cs2010"
    click E3 "https://github.com/guillex7/asm2010/tree/master/src/m2010/cs3"
    click HT "https://github.com/guillex7/asm2010/blob/master/src/hash_table.c"
    click TL "https://github.com/guillex7/asm2010/blob/master/src/trace_log.c"
    click UT "https://github.com/guillex7/asm2010/blob/master/src/utils.h"
    click B1 "https://github.com/guillex7/asm2010/blob/master/CMakeLists.txt"
    click B2 "https://github.com/guillex7/asm2010/tree/master/cmake"
```
