Search results
May 10, 2009 · gcc actually produces assembler and assembles it using the as assembler. Not all compilers do this - the MS compilers produce object code directly, though you can make them generate assembler output. Translating assembler to object code is a pretty simple process, at least compared with C→Assembly or C→Machine-code translation.
Aug 5, 2019 · A compiler does usually convert high-level code directly to machine language, but it can be built in a modular way so that one back-end emits machine code and the other assembly code (like GCC). The code generation phase produces "code" which is some internal representation of machine code, which then has to be converted to a usable format like machine language or assembly code.
Even different compilers for the same language can produce different machine code. One compiler might use different tricks and strategies to try and produce the "optimal machine code". We've moved far past the point where the code of a language is just 1-1 shortcuts for machine code. An analogy could be made to music. Take two songwriters.
Actually there are 3 ways that the code you write is translated to machine code. The very first approach is to translate the entire source program and create the machine code that understandable by the computer. This is the conventional compiler approach. The entire source code is compiled into machine code.
Notice that some compilers are indeed generating directly machine code, and some of them are even generating machine code in the same process that is running the compiler (a typical example of that last case is the SBCL implementation of Common Lisp: every time you interactively type some expression in its REPL, it is getting translated to ...
Not all compilers produce "machine code" (except for the trivial interpretation that all code in some language is machine code for an abstract machine induced by that language). For example, lots of compilers produce ECMAScript source code: CoffeeScript, TypeScript, PureScript, Elm, Opal, GWT, Emscripten, Babel, Clozure, Scala.js, Kotlin, Clue.
People also ask
Does a compiler produce machine code?
What is the difference between a compiler and a machine?
Can a compiler read a source code?
Can a compiler run a program on a processor?
Is assembler a compiler?
Which C/C++ compiler produces machine code directly?
Jan 20, 2023 · Compilers often translate source code for a high-level language, such as C++, to object code for the current computer architecture, such as Intel x64. The object modules produced from multiple ...