美文网首页
A tour of computer systems

A tour of computer systems

作者: Yuxin_Liu | 来源:发表于2021-08-09 11:09 被阅读0次

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.

相关文章

网友评论

      本文标题:A tour of computer systems

      本文链接:https://www.haomeiwen.com/subject/nsqzvltx.html