How tgrysztar/fasm2 works
Project Type and Purpose
• This is an x86 assembler system – a compiler-like tool that assembles source code written in x86 assembly language. Its design emphasizes compatibility with fasm 1 (with some macro syntax changes) and supports multiple OS targets (DOS, Linux, macOS, and Windows).
• The project includes both the assembly “engine” (which reads, parses, and generates machine code) and an integrated set of headers and macros (in the “include” directory) that provide definitions for API calls, instruction sets, and other utilities.
Architectural Breakdown from the File Structure
• Executable Binaries: At the top level, you see executables (fasmg.exe, fasmg.x64, fasmgw.exe) and a command script (fasm2.cmd) that provide the command-line interfaces for different architectures or platforms.
• Examples: The “examples” folder holds various usage demonstrations showing how to employ the assembler in different environments (globstr, tetros, win64avx512). These examples indicate how users might integrate the assembler in real-life assembly coding scenarios.
• Directory: This dense directory holds various “inc” files which supply:
• API headers (e.g., kernel32, shell32, etc.)
• Encoding definitions, macro definitions, equates, file formats (COFF/ELF/PE/MACHO), and instruction set descriptions (e.g., SSE, AVX, MMX).
This component is akin to a standard library that the assembler utilizes to understand and expand source code.
• Source Directory: This is the heart of the assembler engine, broken down into several subcomponents:
• Core Processing Modules (“assembler.inc”, “expressions.inc”, “tables.inc”, “errors.inc”, etc.) – these are likely responsible for parsing the assembly source, managing symbols, computing expressions, and reporting errors.
• Platform-specific Backend Modules (in subdirectories such as “dos”, “linux”, “macos”, “windows”) – these modules tailor the assembly output and system calls to the target operating system.
• IDE Support Modules (under source/ide, including both common IDE code and Windows-specific modules) indicate an integrated development environment component, providing editing, navigation, and other UI-related capabilities.
• Additional libraries (source/libc) handle self-hosting aspects and system-level components likely needed during code generation or linkage.