Below C Level: An Introduction to Computer Systems Norm Matloff University of California, Davis This work is licensed under a Creative Commons Attribution-No Derivative Works 3.0 United States Li- cense. Copyright is retained by N. Matloff in all non-U.S. jurisdictions, but permission to use these materials in teaching is still granted, provided the authorship and licensing information here is displayed. Tux portion of above image drawn by [email protected] using The GIMP. 2 Author’s Biographical Sketch Dr. Norm Matloff is a professor of computer science at the University of California at Davis, and was formerly a professor of mathematics and statistics at that university. He is a former database software developer in Silicon Valley, and has been a statistical consultant for firms such as the Kaiser Permanente Health Plan. Dr. Matloff was born in Los Angeles, and grew up in East Los Angeles and the San Gabriel Valley. He has a PhD in pure mathematics from UCLA, specializing in probability theory and statistics. His current research interests are parallel processing, analysis of social networks, and regression methodology. Prof. Matloff is a former appointed member of IFIP Working Group 11.3, an international committee concerned with database software security, established under UNESCO. He was a founding member of the UC Davis Department of Statistics, and participated in the formation of the UCD Computer Science Department as well. He is a recipient of the campuswide Distinguished Teaching Award and Distinguished Public Service Award at UC Davis. Dr. Matloff is the author of two published textbooks, and of a number of widely-used Web tutorials on com- puter topics, such as the Linux operating system and the Python programming language. He and Dr. Peter Salzman are authors of The Art of Debugging with GDB, DDD, and Eclipse. Prof. Matloff’s book on the R programming language, The Art of R Programming, is due to be published in 2010. He is also the author of several open-source textbooks, including From Algorithms to Z-Scores: Probabilistic and Statistical Mod- eling in Computer Science (http://heather.cs.ucdavis.edu/probstatbook), and Program- ming on Parallel Machines (http://heather.cs.ucdavis.edu/˜matloff/ParProcBook.pdf). Contents 1 Information Representation and Storage 1 1.1 Introduction . 1 1.2 Bits and Bytes . 1 1.2.1 “Binary Digits” . 1 1.2.2 Hex Notation . 2 1.2.3 There Is No Such Thing As “Hex” Storage at the Machine Level! . 4 1.3 Main Memory Organization . 4 1.3.1 Bytes, Words and Addresses . 4 1.3.1.1 The Basics . 4 1.3.1.2 Word Addresses . 5 1.3.1.3 “Endian-ness” . 5 1.3.1.4 Other Issues . 7 1.4 Representing Information as Bit Strings . 9 1.4.1 Representing Integer Data . 9 1.4.2 Representing Real Number Data . 12 1.4.2.1 “Toy” Example . 13 1.4.2.2 IEEE Standard . 13 1.4.3 Representing Character Data . 15 1.4.4 Representing Machine Instructions . 16 i ii CONTENTS 1.4.5 What Type of Information is Stored Here? . 17 1.5 Examples of the Theme, “There Are No Types at the Hardware Level” . 18 1.5.1 Example . 18 1.5.2 Example . 19 1.5.3 Example . 19 1.5.4 Example . 20 1.5.5 Example . 21 1.5.6 Example . 22 1.6 Visual Display . 22 1.6.1 The Basics . 22 1.6.2 Non-English Text . 23 1.6.3 It’s the Software, Not the Hardware . 23 1.6.4 Text Cursor Movement . 24 1.6.5 Mouse Actions . 25 1.6.6 Display of Images . 25 1.7 There’s Really No Such Thing As “Type” for Disk Files Either . 25 1.7.1 Disk Geometry . 25 1.7.2 Definitions of “Text File” and “Binary File” . 26 1.7.3 Programs That Access of Text Files . 27 1.7.4 Programs That Access “Binary” Files . 28 1.8 Storage of Variables in HLL Programs . 28 1.8.1 What Are HLL Variables, Anyway? . 28 1.8.2 Order of Storage . 29 1.8.2.1 Scalar Types . 29 1.8.2.2 Complex Data Structures . 30 1.8.2.3 Pointer Variables . 31 1.8.3 Local Variables . 33 CONTENTS iii 1.8.4 Variable Names and Types Are Imaginary . 33 1.8.5 Segmentation Faults and Bus Errors . 35 1.9 ASCII Table . 37 1.10 An Example of How One Can Exploit Big-Endian Machines for Fast Character String Sorting 38 1.11 How to Inspect the Bits of a Floating-Point Variable . 39 2 Major Components of Computer “Engines” 41 2.1 Introduction . 41 2.2 Major Hardware Components of the Engine . 42 2.2.1 System Components . 42 2.2.2 CPU Components . 45 2.2.2.1 Intel/Generic Components . 45 2.2.2.2 History of Intel CPU Structure . 48 2.2.3 The CPU Fetch/Execute Cycle . 49 2.3 Software Components of the Computer “Engine” . 50 2.4 Speed of a Computer “Engine” . 51 2.4.1 CPU Architecture . 51 2.4.2 Parallel Operations . 52 2.4.3 Clock Rate . 53 2.4.4 Memory Caches . 54 2.4.4.1 Need for Caching . 54 2.4.4.2 Basic Idea of a Cache . 54 2.4.4.3 Blocks and Lines . 55 2.4.4.4 Direct-Mapped Policy . 56 2.4.4.5 What About Writes? . 56 2.4.4.6 Programmability . 57 2.4.4.7 Details on the Tag and Misc. Line Information . 57 iv CONTENTS 2.4.4.8 Why Caches Usually Work So Well . 58 2.4.5 Disk Caches . 58 2.4.6 Web Caches . 58 3 Introduction to Linux Intel Assembly Language 61 3.1 Overview of Intel CPUs . 61 3.1.1 Computer Organization . 61 3.1.2 CPU Architecture . 62 3.1.3 The Intel Architecture . 62 3.2 What Is Assembly Language? . 63 3.3 Different Assemblers . 64 3.4 Sample Program . 64 3.4.1 Analysis . 65 3.4.2 Source and Destination Operands . 70 3.4.3 Remember: No Names, No Types at the Machine Level . 70 3.4.4 Dynamic Memory Is Just an Illusion . 71 3.5 Use of Registers Versus Memory . 72 3.6 Another Example . 72 3.7 Addressing Modes . 76 3.8 Assembling and Linking into an Executable File . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages266 Page
-
File Size-