Computer Translation Hierarchy: Turning Language into 1’s and 0's

What happens when a computer program runs? What happens when a developer compiles a program? These are questions fundamental to the process of Computer translation and are essential in understanding how computers ingest human-friendly languages and turn them into machine code.

computer translation image
Image by Overcoded

Machine Translation Steps

Image by Overcoded

Compiler

The compiler translates the programming language of one machine into the programming language of another. Generally, this process involves converting high-level language such as C into lower-level language like assembly code. The compiler is tasked with several jobs including preprocessing, lexical analysis, and code optimization.

Assembler

The assembly generates object code by translating the code generated by the compiler. Assemblers are tasked with creating a binary version of instructions generated by the compiler. This involves keeping track of labels used in portions of code that recur, such as procedures and static variables. The assembler does this with a Symbol table which consists of symbol:memory_address pairs.

Linker

Sometimes referred to as the link editor, the Linker allows programs to only re-compile certain components rather than re-compiling the entire codebase. The linker gathers all the different assembly language programs generated by the assembler and “links” them together. There are three distinct steps involved in the linker’s role in computer translation:

  1. Looks up addresses of data and instructions from the assembler files
  2. Links the references of procedures and labels from many files to single places in memory

Loader

The loader is responsible for loading the executable file into an operating system’s memory, completing the following sequence of actions:

  1. Copies instructions and data from the linker’s executable file into memory
  2. Copies parameters to the main stack segment in memory
  3. Initializes CPU registers and sets stack pointer to first free location
  4. Copies parameters into appropriate CPU registers and begins execution of the main program terminates on end.

Discussion

Each step in the translation of human-readable code to executable machine code serves an essential purpose. The encapsulation of processes within each step allows programmers from different disciplines and backgrounds to focus on discrete optimizations in ways that all other programmers can develop.

Entrepreneur, Computer Science Student, Designer, and self-confessed health nut that enjoys productivity hacks, developing better habits, and Mother Nature.