Search code examples
compiler-constructionnasm

Assembler Following Code Generation?


I recently asked a question on Software Engineering, but was met with far too many downvotes for a remarkably serious question. As such, I will attempt to rephrase the question a slight bit to make it suited for Stack Overflow.

For the development of a programming language, would it be viable to use the NASM assembler to assemble the resulting assembly code, following the code generation stage in the compiler?

If the answer to that question is no, I would like to ask what should (by convention) be used instead. Some standard bundled up with the current operating system? Some other assembler?

I am aware of LLVM, and how it is normally used for modern compiler creation. The reason I've chosen not to use that is because I want a hands on experience developing my own compiler.


Solution

  • Yes, it is a viable solution and one I used myself in the very early stages of a language development project.

    Pros: Free, multi-platform Cons: It's assembler so knowing the variations of ABI is a requirement of your code.

    As time went on we eventually moved to generating LLVM-IR to leverage it's optimization and multi-architecture targeting capabilities.