A tour of computer systems

Information is Bits + Context

Machines only know bits, either 0 or 1.
Context tells us what do the bits mean. We can distinguish a bunch of bits only when we put them into some context. A String of the same bunch of bits in different contexts can have different meanings.

Programs Are Translated by Other Programs into Different Forms

Basically, we have four steps to translate our program into an executable object program that the system can run.

  1. Preprocessing phase(iso)
    When we write a C program called hello.c, we include system header files, for example, stdio.h.
    In this phase, The preprocessor, modifies the origin C program according to directives that begin with # character:
  • #include <stdio.h> command tells the preprocessor to read the content of stdio.h
  • insert the content of stdio.h into the program text, generate the result hello.i file, it's another C program.
  1. Compile
    In this phase, Complile translates hello.i into hello.s, it's a assembly-language program.
  2. Assemble
    In this phase, Assembler translates hello.s into machine language instructions, then packages them and stores the result into hello.o, it is a binary file whose bytes encode machine language but not characters anymore.
  3. Link
    In this phase, Linker merges hello.o with printf.o, and generates the result of hello file, which is an executable object file.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容