HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Why do compilers produce assembly code?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
whyproducecompilersassemblycode

Problem

Assembly language is converted in to machine language by assembler. Why would a compiler convert high-level language to assembly? Can't it directly convert from the high-level language to machine code?

Solution

Other reason for compilers to produce assembly rather than proper machine code are:

  • The symbolic addresses used by assemblers instead of hard-coding machine addresses


make code relocation much easier.

  • Linking code may involve safety checks such as type-checking, and that's easier


to do with symbolic names.

  • Small changes in machine code are easier to accomodate by changing the assembler


rather than the code generator.

Context

StackExchange Computer Science Q#14749, answer score: 20

Revisions (0)

No revisions yet.