Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas

前言

想法是把所有知识给串联起来。

第一点是软硬件要一起来理解,如:

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第1张图片

第二点是abstraction of layers,比如说是如何从LC-3到C的。嘛,总之之后的文章会体现这两个主题的。

12号考这门课,感觉在考试前整合完是不太可能的(捂脸),因为10号还有门考试,主要是要写的话会假定读者没有一点计算机的基础,那可能就需要补充一些内容吧~

最近打算多写些关于理科和技术的内容,不仅仅是因为自己专业的缘故,还有对各种知识的性质加深的关系。我现在认为至少有三种比较重要的知识,第一种是“自然世界”的知识,第二种是“文化世界”的知识,而第三种是“人的存在”的知识吧,具体来说的话,第一种譬如数学、物理;第二种譬如历史学、政治学、社会学;第三种则是美学和人生哲学。我对自己的评价是,在第一种上面天赋平平,在后两种上面算是小有天赋吧,但并不是说第一种就学不了,只是说上限不一定高吧,摊手。现在的话,是下限有点低了,努力拔高些(捂脸),至少我觉得就“工程学”而言,没有到那种你要去开拓知识边界的层面还是到不了天赋层面的。有天赋可能理解的快些,大概就是这样吧。

然后计划是把Patt&Patel整合完吧。所谓的“整合完”对于读者的期望就是理解“软硬件结合”和“abstraction”的想法,对于我来说,至少还看不到终点(因为把概念理解完了,还要跑代码,还要学下学期的课程——因为还有小学期上到29号,汗流浃背了)。

Computer Memory

When you study pointer variables (in C, in Chapter 17), your knowledge of computer memory will provide a dee[er understanding of what pointers provide, when they should be used, and when they should be avoided.

When you study data structures (in C, in Chapter 19), your knowledge of computer memory will help you better understand what must be done to manipulate the actual structures in memory efficiently.

The Concept of Memory

从这两段可见computer memory的重要性了。不过,computer memory是什么呢?最开始学习的时候是在Chapter 3学的。

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第2张图片

Memory is made up of a (usually large) number of locations, each uniquely identifiable and each having the ability to store a value. We refer to the unique identifier associated with each memory location as its address. We refer to the number of bits of information stored in each location as its addressability.

Address Space

We refer to the total number of uniquely identifiable locations as the memory's address space. A 16 MB memory, for example, refers to a memory that consists of 16 million uniquely identifiable memory locations.

Addressability

The number of bits stored in each memory location is the memory's addressability. A 16 megabyte memory is a memory consisting of 16,777,216 memory locations, each containing 1 byte (8 bits) of storage. 

A 2^2-by-3-Bit Memory

The memory has an address space of four locations, and an addressability of 3 bits. A memory of size 2^2 requires 2 bits to specify the address. A memory of addressability 3 stores 3 bits of information in each memory location.

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第3张图片

Memory of LC-3

这时候另一个想法“abstraction of layers”的重要性就凸显出来了。尽管说register和各种gates构成了memory的实际物理结构,如上图所示,但是如果我们在考虑memory的问题时这么考虑无疑会比较繁琐,那么我们应该如何考虑呢?如下图所示:

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第4张图片

可以看到,在LC-3 computer这里,memory就被简化成了一个框图,只是用来表示数据的读入和读出(毕竟是data path嘛)。当然我们可以进一步分析也会发现MAR,MEMORY,和MDR也能很好地体现动态和静态内存的结构。

如果我们按照memory的物理结构(比如说上面的2^2-by-3-Bit Memory)来考虑数据的读入和读出,其实就不如

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第5张图片

可以看到,数据被装进了一个有地址(如xEFF8)的“框框”中,通过这样来表示“memory”又是另一种办法了。不过,在我们过渡到指针之前,得先把“LC-3"交代清楚:

One of the more obvious changes in the second edition is the replacement of the LC-2 with the LC-3. We insisted on keeping the basic concept of the LC-2: a rich ISA that can be described in a few pages, and hopefully mastered in a short time.

ISA

什么是ISA呢?

The Instruction set architecture (ISA) is the complete specification of the interface between programs that have been written and the underlying computer hardware that must carry out the work of those programs. The ISA specifies the set of instructions the computer can carry out, that is what operations the computer can perform and what data is needed by each operation. The term operand is used  to describe individual data values. The ISA specifies the acceptable representations for operands. They are called data typers. A data typpe is a legitimate representation for an operand such that the computer can perform operations on that representation. The ISA specifies the mechanisms that the computer can use to figure out where the operands are located. These mechanisms are called addressin modes.

LC-3的英文名叫做little computer 3,然后在计算机邻域里有一个很重要的idea是“All computers (the biggest and the smallest, the fastest and the slowest, the most expensive and the cheapest) are capable of computing exactly the same things if they are given enough time and enough memory.”我的理解是LC-3就是一种计算机结构,也能完成对数据的各种操作。各种操作的完成可以通过下面这张图来表示。

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第6张图片

汇编语言(Assembly Language)

“汇编语言”是面向机器的程序设计语言,一个很自然的想法是我们只有能够和LC-3沟通,我们才能让LC-3帮我们完成各种任务。换言之,虽然我们已经知道LC-3是按照上图处理输入数据然后最终给出输出的,但是我们怎么告诉它要完成什么样的操作呢,比如说加法,比如说乘法,比如说取反。“汇编语言”便能让我们和LC-3沟通。那“汇编语言”又是怎样完成和LC-3沟通的呢?

就要从machine code开始说起,我们知道,计算机只能读懂“0”和“1”,那我们自然会想,如果我们输入一串数字,那么计算机就可以解读出这串数字的含义吧。也确实如此。

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第7张图片

各个位的“0”或“1”便按照之前的设计“流到”不同的区域,执行不同的功能。但对于人来说,去记忆一连串数字实在是太过麻烦了,所以就从machine code上升到assembly language。

Patt&Patel-“Introduction to Computing Systems“(1)Basic Ideas_第8张图片

就先这样吧~重点还是放在assembly language和C语言上面,但并不是说上面的内容不重要,我们在理解assembly language和C的时候也要有上述的基础,那么在理解相关概念的时候就会豁然开朗很多吧。 

你可能感兴趣的:(大学课程,c语言,学习,笔记,其他)