#CS250#Computer-Science

  • An assembler takes Assembly Language and transforms it into machine code (1’s and 0’s)
  • We can’t always define labels before we use them.
    • For example, when an if is encountered by the assembler, it doesn’t know exactly how far to skip ahead until it finds the corresponding label
  • As such assemblers require 2 passes over the code
    • First pass - stores each label name and its relative memory address in a symbol table
    • Second pass - Constructs machine code bit strings by
      • Replacing mnemonics, register names, etc. with bit strings placed into fields
      • Using symbol table to fill in the offset with the formula
  • Compilers only take one pass
    • This is due to the fact that compilation is computationally intensive
    • Declaring and defining first is more readable and not much harder than declaring and defining at random
    • It achieves goals faster and more readable