Skip to content

Extract the assembler into a reusable xasm library - #15

Open
epi wants to merge 10 commits into
pfusik:masterfrom
epi:epi/libxasm
Open

Extract the assembler into a reusable xasm library#15
epi wants to merge 10 commits into
pfusik:masterfrom
epi:epi/libxasm

Conversation

@epi

@epi epi commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors xasm so the assembler core can be used as a library (libxasm) from any D program, not just through the xasm command-line tool. xebin is going to be its first user.
All the assembly logic previously living in source/app.d now sits behind an Assembler class in a new source/xasm/package.d module. app.d becomes a thin CLI frontend that drives that class.

What changed

  • New xasm module (source/xasm/package.d): the assembler implementation, moved out of app.d verbatim and wrapped in an Assembler class with a private implementation and a small public surface.
  • I/O is fully decoupled via delegates — the library performs no direct file access or console output. Callers supply:
    • SourceReader / BinaryReader — read source and binary-include files
    • DiagnosticSink — receive warnings and errors as structured Diagnostic values (Severity, filename, line, source line, message)
    • ListingSink — receive the assembly listing and label table line by line
  • Object code is staged through a buffer, exposed via assembler.object, instead of being written straight to a file.
  • Public API documented with ddoc; make libxasm.html generates the library reference. Label is now a struct, and the module carries a documented usage example (runnable as a unittest).

Notes

  • No changes to the assembler's behavior or output for CLI users; this is a structural refactor only.
  • Man page HISTORY section notes that xasm can now be used as a library, without assigning a concrete version number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant