Ebooks-Principles of Computer Organization and Assembly Language: Using the Java Virtual Machine

Principles of Computer Organization and Assembly Language: Using the Java Virtual Machine
by: Patrick Juola

md5: e1242c7eb913299162434e2d11dc6531
size: 2.64 MB [ 2767738 bytes ]
type:
.pdf
status: normal
language: en [ english ]
submitted by: anonymous

metadata:

year: 2007
pages: 334
bookmarked: yes
paginated: yes
vector: yes
cover: yes
searchable: yes
scanned: no

external links: tip: use 7zip to decompress/decrypt all linked archives

no password required ifile.it

> archive password: ebooksclub.org megaupload.com

> archive password: ebooksclub.org mediafire.com




description: ( ? )



Today’s incoming students are more likely to be exposed to Java than ever before. Focusing on a modern architecture (the Java Virtual Machine, or JVM), this text provides a thorough treatment of the principles of computer organization in the context of today’s portable computer. Students are given simple but realistic examples to gain a complete understanding of how computation works on such a machine. Juola makes the material useful and relevant in a course that is often difficult for second-year CS students.

Contents

Preface xiii
Statement of Aims xiii
What xiii
How xiv
For Whom xiv
Acknowledgments xv
I Part the First: Imaginary Computers 1
1 Computation and Representation 3
1.1 Computation 3
1.1.1 Electronic Devices 3
1.1.2 Algorithmic Machines 4
1.1.3 Functional Components 4
1.2 Digital and Numeric Representations 9
1.2.1 Digital Representations and Bits 9
1.2.2 Boolean Logic 12
1.2.3 Bytes and Words 13
1.2.4 Representations 14
1.3 Virtual Machines 27
1.3.1 What is a “Virtual Machine”? 27
1.3.2 Portability Concerns 29
1.3.3 Transcending Limitations 30
1.3.4 Ease of Updates 30
1.3.5 Security Concerns 31
1.3.6 Disadvantages 31
1.4 Programming the JVM 32
1.4.1 Java: What the JVM Isn’t 32
1.4.2 Translations of the Sample Program 34
1.4.3 High- and Low-Level Languages 35
1.4.4 The Sample Program as the JVM Sees It 37
1.5 Chapter Review 38
1.6 Exercises 39
1.7 Programming Exercises 41
2 Arithmetic Expressions 42
2.1 Notations 42
2.1.1 Instruction Sets 42
2.1.2 Operations, Operands, and Ordering 43
2.1.3 Stack-Based Calculators 43
2.2 Stored-Program Computers 45
2.2.1 The fetch-execute Cycle 45
2.2.2 CISC vs. RISC Computers 48
2.3 Arithmetic Calculations on the JVM 49
2.3.1 General Comments 49
2.3.2 A Sample Arithmetic Instruction Set 50
2.3.3 Stack Manipulation Operations 53
2.3.4 Assembly Language and Machine Code 55
2.3.5 Illegal Operations 56
2.4 An Example Program 57
2.4.1 An Annotated Example 57
2.4.2 The Final JVM Code 60
2.5 JVM Calculation Instructions Summarized 60
2.6 Chapter Review 61
2.7 Exercises 62
2.8 Programming Exercises 63
3 Assembly Language Programming in jasmin 64
3.1 Java, the Programming System 64
3.2 Using the Assembler 66
3.2.1 The Assembler 66
3.2.2 Running a Program 66
3.2.3 Display to the Console vs. a Window 67
3.2.4 Using System.out and System.in 68
3.3 Assembly Language Statement Types 71
3.3.1 Instructions and Comments 71
3.3.2 Assembler Directives 72
3.3.3 Resource Directives 73
3.4 Example: Random Number Generation 73
3.4.1 Generating Pseudorandom Numbers 73
3.4.2 Implementation on the JVM 74
3.4.3 Another Implementation 76
3.4.4 Interfacing with Java Classes 77
3.5 Chapter Review 79
3.6 Exercises 79
3.7 Programming Exercises 80
4 Control Structures 82
4.1 “Everything They’ve Taught You Is Wrong” 82
4.1.1 Fetch-Execute Revisited 82
4.1.2 Branch Instructions and Labels 83
4.1.3 “Structured Programming” a Red Herring 83
4.1.4 High-Level Control Structures and Their Equivalents 85
4.2 Types of Gotos 86
4.2.1 Unconditional Branches 86
4.2.2 Conditional Branches 86
4.2.3 Comparison Operations 87
4.2.4 Combination Operations 88
4.3 Building Control Structures 89
4.3.1 If Statements 89
4.3.2 Loops 90
4.3.3 Details of Branch Instructions 92
4.4 Example: Syracuse Numbers 94
4.4.1 Problem Definition 94
4.4.2 Design 94
4.4.3 Solution and Implementation 96
4.5 Table Jumps 97
4.6 Subroutines 101
4.6.1 Basic Instructions 101
4.6.2 Examples of Subroutines 102
4.7 Example: Monte Carlo Estimation of π 105
4.7.1 Problem Definition 105
4.7.2 Design 106
4.7.3 Solution and Implementation 109
4.8 Chapter Review 111
4.9 Exercises 112
4.10 Programming Exercises 112
II Part the Second: Real
Computers 113
5 General Architecture Issues: Real Computers 115
5.1 The Limitations of a Virtual Machine 115
5.2 Optimizing the CPU 116
5.2.1 Building a Better Mousetrap 116
5.2.2 Multiprocessing 116
5.2.3 Instruction Set Optimization 117
5.2.4 Pipelining 117
5.2.5 Superscalar Architecture 120
5.3 Optimizing Memory 121
5.3.1 Cache Memory 121
5.3.2 Memory Management 122
5.3.3 Direct Address Translation 122
5.3.4 Page Address Translation 122
5.4 Optimizing Peripherals 124
5.4.1 The Problem with Busy-Waiting 124
5.4.2 Interrupt Handling 125
5.4.3 Communicating with the Peripherals: Using the Bus 126
5.5 Chapter Review 126
5.6 Exercises 127
6 The Intel 8088 128
6.1 Background 128
6.2 Organization and Architecture 129
6.2.1 The Central Processing Unit 129
6.2.2 The Fetch-Execute Cycle 131
6.2.3 Memory 131
6.2.4 Devices and Peripherals 133
6.3 Assembly Language 133
6.3.1 Operations and Addressing 133
6.3.2 Arithmetic Instruction Set 136
6.3.3 Floating Point Operations 137
6.3.4 Decisions and Control Structures 139
6.3.5 Advanced Operations 142
6.4 Memory Organization and Use 143
6.4.1 Addresses and Variables 143
6.4.2 Byte Swapping 144
6.4.3 Arrays and Strings 145
6.4.4 String Primitives 147
6.4.5 Local Variables and Information Hiding 150
6.4.6 System Stack 151
6.4.7 Stack Frames 152
6.5 Conical Mountains Revisited 156
6.6 Interfacing Issues 157
6.7 Chapter Review 158
6.8 Exercises 159
7 The Power Architecture 160
7.1 Background 160
7.2 Organization and Architecture 161
7.2.1 Central Processing Unit 162
7.2.2 Memory 163
7.2.3 Devices and Peripherals 163
7.3 Assembly Language 164
7.3.1 Arithmetic 164
7.3.2 Floating Point Operations 166
7.3.3 Comparisons and Condition Flags 166
7.3.4 Data Movement 167
7.3.5 Branches 168
7.4 Conical Mountains Revisited 169
7.5 Memory Organization and Use 170
7.6 Performance Issues 171
7.6.1 Pipelining 171
7.7 Chapter Review 174
7.8 Exercises 174
8 The Intel Pentium 175
8.1 Background 175
8.2 Organization and Architecture 176
8.2.1 The Central Processing Unit 176
8.2.2 Memory 177
8.2.3 Devices and Peripherals 177
8.3 Assembly Language Programming 177
8.3.1 Operations and Addressing 177
8.3.2 Advanced Operations 178
8.3.3 Instruction Formats 179
8.4 Memory Organization and Use 180
8.4.1 Memory Management 180
8.5 Performance Issues 180
8.5.1 Pipelining 180
8.5.2 Parallel Operations 182
8.5.3 Superscalar Architecture 182
8.6 RISC vs. CISC Revisited 183
8.7 Chapter Review 184
8.8 Exercises 184
9 Microcontrollers: The Atmel AVR 185
9.1 Background 185
9.2 Organization and Architecture 186
9.2.1 Central Processing Unit 186
9.2.2 Memory 186
9.2.3 Devices and Peripherials 191
9.3 Assembly Language 192
9.4 Memory Organization and Use 193
9.5 Issues of Interfacing 195
9.5.1 Interfacing with External Devices 195
9.5.2 Interfacing with Timers 196
9.6 Designing an AVR Program 197
9.7 Chapter Review 198
9.8 Exercises 199
10 Advanced Programming Topics on the JVM 200
10.1 Complex and Derived Types 200
10.1.1 The Need for Derived Types 200
10.1.2 An Example of a Derived Type: Arrays 201
10.1.3 Records: Classes Without Methods 208
10.2 Classes and Inheritance 210
10.2.1 Defining Classes 210
10.2.2 A Sample Class: String 212
10.2.3 Implementing a String 213
10.3 Class Operations and Methods 214
10.3.1 Introduction to Class Operations 214
10.3.2 Field Operations 214
10.3.3 Methods 217
10.3.4 A Taxonomy of Classes 221
10.4 Objects 223
10.4.1 Creating Objects as Instances of Classes 223
10.4.2 Destroying Objects 224
10.4.3 The Type Object 224
10.5 Class Files and .class File Structure 224
10.5.1 Class Files 224
10.5.2 Starting Up Classes 227
10.6 Class Hierarchy Directives 227
10.7 An Annotated Example: Hello, World Revisited 229
10.8 Input and Output: An Explanation 230
10.8.1 Problem Statement 230
10.8.2 Two Systems Contrasted 231
10.8.3 Example: Reading from the Keyboard in the JVM 234
10.8.4 Solution 235
10.9 Example: Factorials Via Recursion 236
10.9.1 Problem Statement 236
10.9.2 Design 236
10.9.3 Solution 237
10.10 Chapter Review 238
10.11 Exercises 239
10.12 Programming Exercises 239
A Digital Logic 241
A.1 Gates 241
A.2 Combinational Circuits 243
A.3 Sequential Circuits 245
A.4 Computer Operations 248
B JVM Instruction Set 250
C Opcode Summary by Number 281
C.1 Standard Opcodes 281
C.2 Reserved Opcodes 283
C.3 “Quick” Pseudo-Opcodes 283
C.4 Unused Opcodes 284
D Class File Format 285
D.1 Overview and Fundamentals 285
D.2 Subtable Structures 286
D.2.1 Constant Pool 286
D.2.2 Field Table 287
D.2.3 Methods Table 288
D.2.4 Attributes 289
E The ASCII Table 290
E.1 The Table 290
E.2 History and Overview 290
Glossary 293
Index 307