How guillex7/asm2010 works
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.