How fubukimaru/asmsx works
Project type and purpose
• asMSX is a command‐line, Z80 cross‐assembler targeting the MSX home‐computer platform. It reads assembly source, runs a compile‐time pipeline (lexing, parsing, semantic analysis, code generation), and emits binary images or ROMs for MSX.
File structure
• Top‐level:
• src/ ← core assembler implementation in C, Flex and Bison grammar files
• Headers mixed in src/ (.h) and inc folders under code/wrally (example game)
• code/ ← example MSX assembly projects demonstrating assembler output
• doc/ ← manuals, coding style, testing guidelines
• ref/ ← reference docs for Z80 and MSX internals
• test/ ← Python‐based integration tests and Gherkin features
• Dockerfile & .github/workflows ← container image build and CI pipelines
• Makefile ← local build orchestrator using GCC/Flex/Bison
README for additional insights
• Confirms technology stack: GCC, Flex, Bison
• Describes project as GPLv3 Z80 cross‐assembler, usage via CLI or Docker
• Points to testing guide and coding style
Main components
a. Frontend (Source Processing)
– Command‐line Interface (main)
– Flex Lexer (lex.l)
– Bison Parser (dura.y + parser*.l)
– AST/Symbol Table modules (labels.c/.h, types.h)
b. Semantic Analyzer & Intermediate Representation
– labels.c/.h (symbol resolution)
– types.h (operand/type management)
c. Backend & Code Generator
– src/*.c modules that emit Z80 opcodes, handling MSX paging (projects in code/wrally/inc)
– output formatter producing .bin, .rom, or tape images
d. Build & DevOps
– Makefile / Dockerfile orchestrating GCC/Flex/Bison → asmsx binary
– GitHub Actions/workflows for CI, Docker‐build, release drafting
e. Test Harness
– Python environment (test/environment.py)
– Gherkin feature tests (test/features/*.feature)
– Step definitions (test/steps/*.py) invoking the CLI and verifying outputs
Relationships & data flow
– User supplies .asm files → CLI passes them to Flex Lexer → tokens to Bison Parser → build AST → semantic analysis & symbol resolution → code generator emits binary → post‐processing (e.g., UPX compression, packing into .rom) → final MSX image
– Build tools (Make/Docker) orchestrate compilation of C/lexer/parser code → produce asmsx executable
– CI jobs pull source → build container → run tests → publish Docker image & GitHub release
Architectural patterns & principles
– Compiler pipeline (lexer → parser → semantic → codegen)
– Modular C architecture: separate translation units for lexing, parsing, symbol management, and output
– Assembler extensibility: grammar in Bison, Z80 instructions data‐driven where possible
– CI/CD flow decoupled via container images