3 cPU Architecture 87 All About Memory and the CPU 88 Memory Has Assigned Addresses 89 Data Passes Through the Bus 92 Bus Width and Bits 94 R W Signals and I O Signals 98 Instructions Are Made of Operands and Opcodes 101 Accumulators and Other Registers Are Used in Operations 103 CPU Instruction Processing 106 Classic CPU Architecture 106 The Instruction Cycle 107 The Instruction We Process Changes Depending on the Program Counter 112 All Kinds of Memory Devices 115 A Comparison Between HDD and Memory 116 RAM Space ROM Space and I O Space 119 What Are Interrupts 122 Interrupts Are Useful 122 The Stack and the Stack Pointer 126 Interrupt Priority 128 Memory Classifications 132 I O Ports and the GPU 132 Clock Frequency and Degrees of Accuracy 133 Clock Generators 134 Timer Interrupts 135 Reset Signals 136 CPU Performance Is Measured in FLOPS 137 4 operations 139 Types of Operations 140 There Are Many Types of Instructions 142 Instructions for Arithmetic and Logic Operations 144 What Are Bit Shifts 145 The Sign Bit Lets Us Express Negative Binary Numbers 147 Logical Shifts and Arithmetic Shifts 149 Circular Shifts Rotating Shifts 152 Data Transfer Operations 153 Input Output Instructions 154 Branch Instructions 155 Condition Evaluation and Status Flags 158 Putting Branches and Condition Evaluation Together 161 Operand Types 162 How Many Operands Do We Have 162 Operands Take Many Forms 165 Immediate Value Processing 166 Address References 167 viii contents
What Are Addressing Modes 168 Addressing Mode Overview 172 The Structure of Operations in the ALU 176 A Look Inside the ALU 176 Basic Circuit Architecture of the 74S181 178 Serial Transmission and Parallel Transmission 185 An Overview of Some Basic Registers 186 An Overview of Some Basic Status Flags 187 The SLEEP Instruction 188 5 Programs 189 Assembly and High-Level Languages 190 What Are Assembly Languages 192 The Characteristics of Assembly Languages and High-Level Languages 194 The Difference Between Programs and Source Code 199 Program Basics 200 What Can You Make Using Conditions and Jumps 200 What Should We Make the Computer Do 204 Where are Programs Stored 208 What Happens Before a Program Is Executed 208 6 Microcontrollers 211 What Are Microcontrollers 212 Microcontrollers Are in All Kinds of Products 213 The Function of a Microcontroller 214 Architecture of a Microcontroller 219 What Are DSPs 222 DSPs and Multiplier-Accumulate Operations 224 Microcontrollers in Industrial Machines 224 epilogue 227 Afterword 239 index 241 contents ix
Preface Ever since the 1950s when computers saw their debut in markets all over the world inter est in information technology IT has seen a steady rise The core that supports this tech nology is a semiconductor known as the CPU or central processing unit Since the start of the 21st century advancements in circuit design theory and manufacturing technology have led to rapid progress in both processing speed and chip size allowing us to embed them in most of the electronics we use on a daily basis In addition to personal computers smart phones and tablets you’ll even find CPUs in things like air conditioners refrigerators wash ing machines and other major appliances just to name a few It’s worth noting that the CPUs found in modern PCs are extremely powerful and many of their applications are outside the scope of this book We also will not delve into computer architecture which has had a research boom in recent years Instead I think that the best way to give insight into what CPUs are and by extension how programs work is to go back and analyze how the first CPUs worked and examine the concepts and principles by which they were designed Let me share an allegory with you It’s been quite some time since we first started taking automobiles for granted in our daily lives but despite their ubiquity very few people today can explain how an engine works or how the energy generated by the engine gets translated into forward momentum for the car In the 1950s you had to answer engine design questions on your driver’s license examination but no such questions remain in today’s tests Essentially this means that to learn things about the internals of a car engine today you really have to be an incredibly curious person In that vein my wish is that this book will not only act as a platform to teach readers a range of different topics but also to sate their curiosity on the subject by having them learn some of the deeper principles of the CPUs that have so nonchalantly permeated our daily lives In regards to the publication of this book I would like to thank Sawako Sawada of Office sawa who thought up the fun story and Takashi Tonagi for the illustration work Michio shibuya November 2014