CHAPTER 1 ----- a tour of computer sysytems(1)

news/2024/7/7 13:24:18

1.1Information is bits + context.

  All information in a system——including disk files,programs stored in memory ,user data stored in memory ,and data transferred across a network——is represented as a bunch of bits.The only thing that distinguished different data objects is the context in which we view them.

  系统中所有的信息——包括磁盘文件,内存中的程序,内存中存放的用户数据以及网络上传送的数据——都是由一串比特表示,区分不同数据数据对象的唯一方法是我们读到这些数据时的上下文。

  For example, in different contexts,the same sequence of bytes might represent an integer, floating-point number,character string ,or machine instruction,

  A source program (hello.c) is a sequence of bits,each with a value of 0 or 1 ,organized in 8-bits chunks called bytes.Most modern systems represent text characters(文本字符)using ASCII standard that represents each character with a unique byte-sized integer value.

  The hello.c program is stored in a file as a sequence of bytes.Notice that each text line is terminated by the invisible newline character '\n'(which is represented by the integer value 10). Files(文件) such as hello.c that consist exclusively(唯一的) of ASCII character are know as text files(文本文件).

 include<stdio.h>

 

int main()

{

  printf("hello world\n");

}

 

1.2 Programs are translated by other progrems into different forms

hello.c can be read and undertand by human beings.In order to run hello,c on the system,the individual C statements must be translated by the compiler driver into a sequence of machine-language instruction.These instructions are then packaged in a form called an executable object program and stored as a binary disk file.

 

预处理器:preprocessor(cpp);编译器:compiler(cc1);汇编器:assembler(as);链接器Linker(ld);

Preprocessor phase(预处理阶段).The preprocessor(cpp)modifies the original C program accroding to directives that begin with the # character.Eg:insert stdio.h directly into the program text and the result is another C program,typcally with the .i suffix(后缀).

Compilation phase.The compiler(cc1)translates  the text file hello.i into hello.s,which contains an assembly-language program.Eg:hello.s contains the definition of function main:

each statement(2-7) in an assembly-language program exactly describes one low-level machine-language instruction in a standard text form.Assembly language provides a common output language for different compilers for different high-level languages.

Assembly phase.the assembler(as) translates hello.s into machine-language instructions,pachages them in a form known as a relocatable object program(可重定位目标程序),and stores the result in the object file hello.o.The hello.o file is a binary file whose bytes encode machine language instruction rather than charaters.If we  were to view hello.o with a text editor ,it would appear to be gibberish(乱码).

Linking phase.The linker(ld) handles this merging,which merge printf.o (because of the function printf) with our hello.o.The result is the hello file,which is an executable object file  that is ready to be loaded into memory  and executed by the system.

 

 

  

 

转载于:https://www.cnblogs.com/SsoZhNO-1/p/8822213.html


http://www.niftyadmin.cn/n/3141271.html

相关文章

关于Linux磁盘分区与双系统

Linux是一个很大的东西&#xff0c;而且稍微按照鸟哥的书做点网络上的扩展就会有很多很多的东西&#xff0c;常常会使得自己迷失&#xff0c;所以我认为在学习的时候&#xff0c;还是应该有自己的目标&#xff0c;写出关于目标的博客&#xff0c;不要什么都讲&#xff0c;却什么…

手把手教你如何新建scrapy爬虫框架的第一个项目(下)

前几天小编带大家学会了如何在Scrapy框架下创建属于自己的第一个爬虫项目&#xff08;上&#xff09;&#xff0c;今天我们进一步深入的了解Scrapy爬虫项目创建&#xff0c;这里以伯乐在线网站的所有文章页为例进行说明。在我们创建好Scrapy爬虫项目之后&#xff0c;会得到上图…

01. 机器学习基础

2019独角兽企业重金招聘Python工程师标准>>> # 机器学习基础 # 线性回归模型import numpy as np import matplotlib.pyplot as plt import tensorflow as tf# 从0到10取30个值 data_x np.linspace(0, 10, 30)# np.random.normal(0, 1, 30): 噪声&#xff0c;从0到1…

bash1---基本0

最近在看《高级BASH脚本编程》&#xff0c;边学习脚本编程&#xff0c;边学习Linux的命令。 另外还解决了笔记本电脑上关于Ubuntu无法找到wifi适配器的问题。具体看我另外一篇博客。 另外推荐一个学习linux命令的网站。 今天主要想讲一下如何备份最后一天所有修改的文件 #!/bin…

效能改进之项目例会导入实践

众所周知&#xff0c;在项目管理的过程中&#xff0c;我们需要非常注重沟通&#xff0c;而每日例会作为沟通管理中的一项最佳实践&#xff0c;非常适配互联网项目短频快的特点。成功地在项目中建立例会制度&#xff0c;能带来以下好处&#xff1a; 1&#xff09;让研发人员相互…

bash2----基本1

这个随笔主要讲一些关于bash的小track 1、如何注释多行bash: :<< 注释内容 &#xff1a;<<WORD 注释内容 WORD :<<BLOCK 注释内容 BLOCK 1.1这个是补充的一个知识点&#xff1a; 命令替换用的点是&#xff0c;在左上角 ESC下面那个&#xff0c;而不是单引号…

【转】利用telnet来进行调试Skynet

https://blog.csdn.net/WhereIsHeroFrom/article/details/80674408转载于:https://www.cnblogs.com/colourstar/p/10432057.html

js,jquery,数组操作小结

----------------------------------------------------------定义数组---------------------------------------------------------- $(function(){var aArray {};//定义一个数组aArray[name] "张三";aArray[sex] "男";aArray[mail] "123456qq.…