Historically, C compilers really did run an assembler in a separate process and communicate with it via pipes or files. gcc still ships with gas. gas is more oriented to the needs of a compiler than to human writers of assembly code.
Some compilers emit machine code from their own low-level intermediate representation, though. The trade-offs are similar to any other build/buy technical decision: full-custom gives you more control, while forcing you to reinvent the wheel.
One can assemble directly in your language of choice. See http://code.weinholt.se/industria/ for a particularly terse example: 1300 lines for an x86 assembler.
Comments
I'm assuming most compilers don't ship nasm/masm/whatever with them. How do compilers do actual "assembly to executable" step?
Historically, C compilers really did run an assembler in a separate process and communicate with it via pipes or files. gcc still ships with gas. gas is more oriented to the needs of a compiler than to human writers of assembly code.
Some compilers emit machine code from their own low-level intermediate representation, though. The trade-offs are similar to any other build/buy technical decision: full-custom gives you more control, while forcing you to reinvent the wheel.
One can assemble directly in your language of choice. See http://code.weinholt.se/industria/ for a particularly terse example: 1300 lines for an x86 assembler.
Link to source: http://bazaar.launchpad.net/~weinholt/scheme-libraries/indus...