Write Great Code, Volume 1, 2nd Edition

Book description

This, the first volume in Randall Hyde’s Write Great Code series, dives into machine organization without the extra overhead of learning assembly language programming. Written for high-level language programmers, Understanding the Machine fills in the low-level details of machine organization that are often left out of computer science and engineering courses.

Learn:

•How the machine represents numbers, strings, and high-level data structures, so you’ll know the inherent cost of using them.
•How to organize your data, so the machine can access it efficiently.
•How the CPU operates, so you can write code that works the way the machine does.
•How I/O devices operate, so you can maximize your application’s performance when accessing those devices.
•How to best use the memory hierarchy to produce the fastest possible programs.

Great code is efficient code. But before you can write truly efficient code, you must understand how computer systems execute programs and how abstractions in programming languages map to the machine’s low-level hardware. After all, compilers don’t write the best machine code; programmers do. This book gives you the foundation upon which all great software is built.

NEW IN THIS EDITION, COVERAGE OF:

•Programming languages like Swift and Java
•Code generation on modern 64-bit CPUs
•ARM processors on mobile phones and tablets
•Newer peripheral devices
•Larger memory systems and large-scale SSDs

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. About the Author
  5. About the Technical Reviewer
  6. BRIEF CONTENTS
  7. CONTENTS IN DETAIL
  8. ACKNOWLEDGMENTS
  9. 1 WHAT YOU NEED TO KNOW TO WRITE GREAT CODE
    1. 1.1 The Write Great Code Series
    2. 1.2 What This Book Covers
    3. 1.3 Assumptions This Book Makes
    4. 1.4 Characteristics of Great Code
    5. 1.5 The Environment for This Book
    6. 1.6 Additional Tips
    7. 1.7 For More Information
  10. 2 NUMERIC REPRESENTATION
    1. 2.1 What Is a Number?
    2. 2.2 Numbering Systems
    3. 2.3 Numeric/String Conversions
    4. 2.4 Internal Numeric Representation
    5. 2.5 Signed and Unsigned Numbers
    6. 2.6 Useful Properties of Binary Numbers
    7. 2.7 Sign Extension, Zero Extension, and Contraction
    8. 2.8 Saturation
    9. 2.9 Binary-Coded Decimal Representation
    10. 2.10 Fixed-Point Representation
    11. 2.11 Scaled Numeric Formats
    12. 2.12 Rational Representation
    13. 2.13 For More Information
  11. 3 BINARY ARITHMETIC AND BIT OPERATIONS
    1. 3.1 Arithmetic Operations on Binary and Hexadecimal Numbers
    2. 3.2 Logical Operations on Bits
    3. 3.3 Logical Operations on Binary Numbers and Bit Strings
    4. 3.4 Useful Bit Operations
    5. 3.5 Shifts and Rotates
    6. 3.6 Bit Fields and Packed Data
    7. 3.7 Packing and Unpacking Data
    8. 3.8 For More Information
  12. 4 FLOATING-POINT REPRESENTATION
    1. 4.1 Introduction to Floating-Point Arithmetic
    2. 4.2 IEEE Floating-Point Formats
    3. 4.3 Normalization and Denormalized Values
    4. 4.4 Rounding
    5. 4.5 Special Floating-Point Values
    6. 4.6 Floating-Point Exceptions
    7. 4.7 Floating-Point Operations
    8. 4.8 For More Information
  13. 5 CHARACTER REPRESENTATION
    1. 5.1 Character Data
    2. 5.2 Character Strings
    3. 5.3 Character Set Data Types
    4. 5.4 Designing Your Own Character Set
    5. 5.5 For More Information
  14. 6 MEMORY ORGANIZATION AND ACCESS
    1. 6.1 The Basic System Components
    2. 6.2 Physical Organization of Memory
    3. 6.3 Big-Endian vs. Little-Endian Organization
    4. 6.4 The System Clock
    5. 6.5 CPU Memory Access
    6. 6.6 For More Information
  15. 7 COMPOSITE DATA TYPES AND MEMORY OBJECTS
    1. 7.1 Pointer Types
    2. 7.2 Arrays
    3. 7.3 Records/Structures
    4. 7.4 Discriminant Unions
    5. 7.5 Classes
    6. 7.6 Classes in C++
    7. 7.7 Classes in Java
    8. 7.8 Classes in Swift
    9. 7.9 Protocols and Interfaces
    10. 7.10 Generics and Templates
    11. 7.11 For More Information
  16. 8 BOOLEAN LOGIC AND DIGITAL DESIGN
    1. 8.1 Boolean Algebra
    2. 8.2 Boolean Functions and Truth Tables
    3. 8.3 Function Numbers
    4. 8.4 Algebraic Manipulation of Boolean Expressions
    5. 8.5 Canonical Forms
    6. 8.6 Simplification of Boolean Functions
    7. 8.7 What Does This Have to Do with Computers, Anyway?
    8. 8.8 For More Information
  17. 9 CPU ARCHITECTURE
    1. 9.1 Basic CPU Design
    2. 9.2 Decoding and Executing Instructions: Random Logic vs. Microcode
    3. 9.3 Executing Instructions, Step by Step
    4. 9.4 RISC vs. CISC: Improving Performance by Executing More, Faster, Instructions
    5. 9.5 Parallelism: The Key to Faster Processing
    6. 9.6 For More Information
  18. 10 INSTRUCTION SET ARCHITECTURE
    1. 10.1 The Importance of Instruction Set Design
    2. 10.2 Basic Instruction Design Goals
    3. 10.3 The Y86 Hypothetical Processor
    4. 10.4 Encoding 80x86 Instructions
    5. 10.5 Implications of Instruction Set Design to the Programmer
    6. 10.6 For More Information
  19. 11 MEMORY ARCHITECTURE AND ORGANIZATION
    1. 11.1 The Memory Hierarchy
    2. 11.2 How the Memory Hierarchy Operates
    3. 11.3 Relative Performance of Memory Subsystems
    4. 11.4 Cache Architecture
    5. 11.5 NUMA and Peripheral Devices
    6. 11.6 Virtual Memory, Memory Protection, and Paging
    7. 11.7 Writing Software That Is Cognizant of the Memory Hierarchy
    8. 11.8 Runtime Memory Organization
    9. 11.9 For More Information
  20. 12 INPUT AND OUTPUT
    1. 12.1 Connecting a CPU to the Outside World
    2. 12.2 Other Ways to Connect Ports to the System
    3. 12.3 I/O Mechanisms
    4. 12.4 I/O Speed Hierarchy
    5. 12.5 System Buses and Data Transfer Rates
    6. 12.6 Buffering
    7. 12.7 Handshaking
    8. 12.8 Timeouts on an I/O Port
    9. 12.9 Interrupts and Polled I/O
    10. 12.10 Protected-Mode Operation and Device Drivers
    11. 12.11 For More Information
  21. 13 COMPUTER PERIPHERAL BUSES
    1. 13.1 The Small Computer System Interface
    2. 13.2 The IDE/ATA Interface
    3. 13.3 The Universal Serial Bus
    4. 13.4 For More Information
  22. 14 MASS STORAGE DEVICES AND FILESYSTEMS
    1. 14.1 Disk Drives
    2. 14.2 Tape Drives
    3. 14.3 Flash Storage
    4. 14.4 RAM Disks
    5. 14.5 Solid-State Drives
    6. 14.6 Hybrid Drives
    7. 14.7 Filesystems on Mass Storage Devices
    8. 14.8 Writing Software That Manipulates Data on a Mass Storage Device
    9. 14.9 For More Information
  23. 15 MISCELLANEOUS INPUT AND OUTPUT DEVICES
    1. 15.1 Exploring Specific PC Peripheral Devices
    2. 15.2 Mice, Trackpads, and Other Pointing Devices
    3. 15.3 Joysticks and Game Controllers
    4. 15.4 Sound Cards
    5. 15.5 For More Information
  24. AFTERWORD: THINKING LOW-LEVEL, WRITING HIGH-LEVEL
  25. A ASCII CHARACTER SET
  26. GLOSSARY
  27. INDEX

Product information

  • Title: Write Great Code, Volume 1, 2nd Edition
  • Author(s): Randall Hyde
  • Release date: August 2020
  • Publisher(s): No Starch Press
  • ISBN: 9781718500365