Introduction to Computer Organization

Book description

Introduction to Computer Organization gives programmers a practical understanding of what happens in a computer when you execute your code. You may never have to write x86-64 assembly language or design hardware yourself, but knowing how the hardware and software works will give you greater control and confidence over your coding decisions. We start with high level fundamental concepts like memory organization, binary logic, and data types and then explore how they are implemented at the assembly language level.

The goal isn’t to make you an assembly programmer, but to help you comprehend what happens behind the scenes between running your program and seeing “Hello World” displayed on the screen. Classroom-tested for over a decade, this book will demystify topics like:

•How to translate a high-level language code into assembly language
•How the operating system manages hardware resources with exceptions and interrupts
•How data is encoded in memory
•How hardware switches handle decimal data
•How program code gets transformed into machine code the computer understands
•How pieces of hardware like the CPU, input/output, and memory interact to make the entire system work.

Table of contents

  1. Title Page
  2. Copyright
  3. About the Author
  4. Preface
    1. Who This Book Is For
    2. About This Book
      1. The Programming in the Book
      2. Why Read This Book?
      3. Chapter Organization
    3. Efficient Use of This Book
  5. Acknowledgments
  6. Chapter 1: Setting the Stage
    1. Computer Subsystems
    2. Program Execution
    3. The Programming Environment
    4. What You’ve Learned
  7. Chapter 2: Data Storage Formats
    1. Describing Switches and Groups of Switches
      1. Representing Switches with Bits
      2. Representing Groups of Bits
      3. Using Hexadecimal Digits
    2. The Mathematical Equivalence of Binary and Decimal
      1. Getting to Know Positional Notation
      2. Converting Binary to Unsigned Decimal
      3. Converting Unsigned Decimal to Binary
    3. Storing Data in Memory
      1. Expressing Memory Addresses
      2. Characters
      3. Unsigned Integers
    4. Exploring Data Formats with C
      1. C and C++ I/O Libraries
      2. Writing and Executing Your First C Program
    5. Examining Memory with a Debugger
      1. Using Your Debugger
      2. Understanding Byte Storage Order in Memory
    6. What You’ve Learned
  8. Chapter 3: Computer Arithmetic
    1. Adding and Subtracting Unsigned Integers
      1. Adding in the Decimal Number System
      2. Subtracting in the Decimal Number System
      3. Adding and Subtracting Unsigned Integers in Binary
    2. Adding and Subtracting Signed Integers
      1. Two’s Complement
      2. Computing Two’s Complement
      3. Adding and Subtracting Signed Integers in Binary
      4. Circular Nature of Integer Codes
    3. What You’ve Learned
  9. Chapter 4: Boolean Algebra
    1. Basic Boolean Operators
    2. Boolean Expressions
    3. Boolean Algebra Rules
      1. Boolean Algebra Rules That Are the Same as Elementary Algebra
      2. Boolean Algebra Rules That Differ from Elementary Algebra
    4. Boolean Functions
      1. Canonical Sum or Sum of Minterms
      2. Canonical Product or Product of Maxterms
      3. Comparison of Canonical Boolean Forms
    5. Boolean Expression Minimization
      1. Minimal Expressions
      2. Minimization Using Algebraic Manipulations
      3. Minimization Using Karnaugh Maps
    6. Combining Basic Boolean Operators
    7. What You’ve Learned
  10. Chapter 5: Logic Gates
    1. Crash Course in Electronics
      1. Power Supplies and Batteries
      2. Passive Components
    2. Transistors
      1. MOSFET Switch
      2. CMOS Switch
    3. NAND and NOR Gates
    4. NAND as a Universal Gate
    5. What You’ve Learned
  11. Chapter 6: Combinational Logic Circuits
    1. The Two Classes of Logic Circuits
    2. Adders
      1. Half Adder
      2. Full Adder
      3. Full Adder from Two Half Adders
      4. Ripple-Carry Addition and Subtraction Circuits
    3. Decoders
    4. Multiplexers
      1. Tristate Buffer
    5. Programmable Logic Devices
      1. Programmable Logic Array
      2. Read-Only Memory
      3. Programmable Array Logic
    6. What You’ve Learned
  12. Chapter 7: Sequential Logic Circuits
    1. Latches
      1. SR Latch Using NOR Gates
      2. SR Latch Using NAND Gates
      3. SR Latch with Enable
      4. The D Latch
    2. Flip-Flops
      1. Clocks
      2. D Flip-Flop
      3. T Flip-Flop
      4. JK Flip-Flop
    3. Designing Sequential Logic Circuits
      1. Designing a Counter
      2. Designing a Branch Predictor
    4. What You’ve Learned
  13. Chapter 8: Memory
    1. The Memory Hierarchy
      1. Mass Storage
      2. Main Memory
      3. Cache Memory
      4. Registers
    2. Implementing Memory in Hardware
      1. Four-Bit Register
      2. Shift Register
      3. Register File
      4. Read-Write Memory
      5. Static Random-Access Memory
      6. Dynamic Random-Access Memory
    3. What You’ve Learned
  14. Chapter 9: Central Processing Unit
    1. CPU Overview
      1. CPU Subsystems
      2. Instruction Execution Cycle
    2. x86-64 Registers
      1. General-Purpose Registers
      2. Status Register
    3. C/C++ Integral Data Types and Register Sizes
    4. Using gdb to View the CPU Registers
    5. What You’ve Learned
  15. Chapter 10: Programming in Assembly Language
    1. Compiling a Program Written in C
    2. From C to Assembly Language
      1. Assembler Directives That We Won’t Use
      2. Assembler Directives That We Will Use
    3. Creating a Program in Assembly Language
      1. Assembly Language in General
      2. First Assembly Language Instructions
      3. Minimal Processing in a Function
      4. Using gdb to Learn Assembly Language
    4. AT&T Syntax
    5. What You’ve Learned
  16. Chapter 11: Inside the main Function
    1. The write and read System Call Functions
    2. Passing Arguments in Registers
    3. Position-Independent Code
    4. The Call Stack
      1. Stacks in General
      2. Inside the Function Prologue and Epilogue
    5. Local Variables in a Function
      1. Variables on the Stack
      2. Stack Corruption
    6. Not Using the C Runtime Environment
    7. What You’ve Learned
  17. Chapter 12: Instruction Details
    1. Looking at Machine Code
    2. Instruction Bytes
      1. Opcode Bytes
      2. ModR/M Byte
      3. REX Prefix Byte
    3. Immediate Addressing Mode
    4. Memory Addressing Modes
      1. Direct Memory Addressing
      2. Register Indirect with Offset
      3. Register Indirect with Indexing
      4. SIB Byte
    5. Jump Instructions
    6. Assemblers and Linkers
      1. The Assembler
      2. The Linker
    7. What You’ve Learned
  18. Chapter 13: Control Flow Constructs
    1. Jumps
      1. Unconditional Jumps
      2. Conditional Jumps
    2. Iteration
      1. while Loop
      2. for Loop
      3. do-while Loop
    3. Selection
      1. if Conditional
      2. if-then-else Conditional
      3. switch Conditional
    4. What You’ve Learned
  19. Chapter 14: Inside Subfunctions
    1. Scope of Variable Names in C
    2. Overview of Passing Arguments
    3. Global Variables
    4. Explicitly Passing Arguments
      1. Passing Arguments in C
      2. What’s Going On in Assembly Language
    5. Handling More Than Six Arguments
      1. Pushing Arguments onto the Stack
      2. Storing Arguments Directly on the Stack
      3. Summary of Stack Frame Usage
    6. Static Local Variables
    7. What You’ve Learned
  20. Chapter 15: Special Uses of Subfunctions
    1. Recursion
    2. Accessing CPU Features in Assembly Language
      1. A Separate Function Written in Assembly Language
      2. Inline Assembly Language
    3. What You’ve Learned
  21. Chapter 16: Computing with Bitwise Logic, Multiplication, and Division Instructions
    1. Bit Masking
      1. Bit Masking in C
      2. Logic Instructions
      3. Bit Masking in Assembly Language
    2. Shifting Bits
      1. Shifting Bits in C
      2. Shift Instructions
      3. Shifting Bits in Assembly Language
    3. Multiplication
      1. Multiplication in C
      2. Multiply Instructions
      3. Multiplication in Assembly Language
    4. Division
      1. Division in C
      2. Division Instructions
      3. Division in Assembly Language
    5. What You’ve Learned
  22. Chapter 17: Data Structures
    1. Arrays
      1. Arrays in C
      2. Arrays in Assembly Language
    2. Records
      1. Records in C
      2. Records in Assembly Language
      3. Passing Records to Other Functions in C
      4. Passing Records to Other Functions in Assembly Language
    3. What You’ve Learned
  23. Chapter 18: Object-Oriented Programming
    1. Objects in C++
      1. Using Objects in C++
      2. Defining Class Member Functions
      3. Letting the Compiler Write a Constructor and Destructor
    2. Objects in Assembly Language
    3. What You’ve Learned
  24. Chapter 19: Fractional Numbers
    1. Fractional Values in Binary
    2. Fixed-Point Numbers
      1. When the Fractional Part Is a Sum of Inverse Powers of Two
      2. When the Fractional Part Is in Decimal
    3. Floating-Point Numbers
      1. Floating-Point Representation
      2. IEEE 754 Floating-Point Standard
      3. SSE2 Floating-Point Hardware
      4. xmm Registers
      5. Programming with Floating-Point Numbers
      6. Floating-Point Arithmetic Errors
    4. Comments About Numerical Accuracy
    5. What You’ve Learned
  25. Chapter 20: Input/Output
    1. Timing Considerations
      1. Memory Timing
      2. I/O Device Timing
      3. Bus Timing
    2. Accessing I/O Devices
      1. Port-Mapped I/O
      2. Memory-Mapped I/O
    3. I/O Programming
      1. Polled I/O
      2. Interrupt-Driven I/O
      3. Direct Memory Access
    4. Polled I/O Programming Algorithms
      1. UART Memory-Mapped I/O in C
      2. UART Memory-Mapped I/O in Assembly Language
      3. UART Port-Mapped I/O
    5. What You’ve Learned
  26. Chapter 21: Interrupts and Exceptions
    1. Privilege Levels
    2. CPU Response to an Interrupt or Exception
      1. External Interrupts
      2. Exceptions
      3. Software Interrupts
    3. System Calls
      1. The int 0x80 Software Interrupt
      2. The syscall Instruction
    4. What You’ve Learned
  27. Index

Product information

  • Title: Introduction to Computer Organization
  • Author(s): Robert G. Plantz
  • Release date: January 2022
  • Publisher(s): No Starch Press
  • ISBN: 9781718500099