没有合适的资源?快使用搜索试试~ 我知道了~
首页理解机器:优秀编程之道 - Randall Hyde 原版
理解机器:优秀编程之道 - Randall Hyde 原版
5星 · 超过95%的资源 需积分: 10 58 下载量 12 浏览量
更新于2024-07-21
2
收藏 5.28MB PDF 举报
"《写出伟大的代码:理解机器》(Write Great Code: Understanding the Machine)是 Randall Hyde 著作的一本经典IT专业书籍,第四版(V413HAV)针对程序员和计算机科学爱好者提供了深入理解计算机工作原理的洞察。该书专注于汇编语言编程,它不仅是技术教程,也是一本启发思考底层机制的指南。 本书分为Volume I,详细阐述了机器级编程的基础,包括计算机硬件如何执行指令、内存的工作方式、处理器架构以及汇编语言的重要性。作者强调通过实践学习,让读者亲自动手编写汇编代码,以便更好地理解和优化程序性能。书中内容涵盖了指令集架构(ISA)、寻址方式、数据类型转换、异常处理等核心概念,这些都是现代软件开发中不可或缺的知识。 版权方面,所有权利由 Randall Hyde 保留,未经版权所有者和出版社的书面许可,不得以任何形式复制或传播,无论是电子的还是机械的,如复印、录音或通过任何信息存储和检索系统。这体现了对知识产权的尊重和保护。 No Starch Press 出版社出版此书,采用环保纸张印刷,强调可持续性。出版团队包括威廉·波洛克(Publisher)、编辑人员、设计师、技术审阅员和校对人员,他们共同确保了内容的专业性和质量。 《写出伟大的代码》旨在帮助读者跨越抽象层次,深入到计算机硬件的底层,从而提升编程技能,写出更加高效和可维护的代码。对于那些希望在IT领域深入发展,特别是从事嵌入式系统、操作系统内核或者需要理解硬件与软件交互的开发者来说,这本书是一本极具价值的学习资料。"
资源详情
资源推荐
xvi Acknowledgments
Stephanie Provines, whose proofreading caught several typographical
and layout errors.
Leigh Sacks, who has done a great job of marketing this book and my
earlier book, The Art of Assembly Language.
And of course, all the great people at No Starch Press who’ve been suppor-
tive of this project from the very beginning.
Last, but not least, I would like to thank my wife, Mandy, who allowed
me to get away with not spending as much time working around the house
as I should have, so that I could get this book out the door.
Thanks to all of you,
Randall Hyde
No Starch Press, Copyright © 2004 by Randall Hyde
1
WHAT YOU NEED TO KNOW TO
WRITE GREAT CODE
Write Great Code will teach you how to write
code you can be proud of, code that will
impress other programmers, code that will
satisfy customers and prove popular with
users, and code that people (customers, your boss, and so
on) won’t mind paying top dollar to obtain. In general,
the volumes in the Write Great Code series will discuss
how to write software that achieves legendary status,
eliciting the awe of other programmers.
1.1 The Write Great Code Series
Write Great Code: Understanding the Machine is the first of four volumes in the Write
Great Code series. Writing great code requires a combination of knowledge,
experience, and skill that programmers usually obtain only after years of mistakes
No Starch Press, Copyright © 2004 by Randall Hyde
2 Chapter 1
and discoveries. The purpose of this series is to share with both new and
experienced programmers a few decade’s worth of observations and
experience. I hope that these books will help shorten the time and reduce
the frustration that it takes to learn things “the hard way.”
This first volume, Understanding the Machine, is intended to fill in the low-
level details that are often skimmed over in a typical computer science or
engineering curriculum. The information in this volume is the foundation
upon which great software is built. You cannot write efficient code without
this information, and the solutions to many problems require a thorough
grounding in this subject. Though I’m attempting to keep each volume as
independent as possible of the others, Understanding the Machine might be
considered a prerequisite for all the following volumes.
The second volume, Thinking Low-Level, Writing High-Level, will immedi-
ately apply the knowledge gained in this first volume. Thinking Low-Level,
Writing High-Level will teach you how to analyze code written in a high-level
language to determine the quality of the machine code that a compiler
would generate for that code. Armed with this knowledge, you will be able
to write high-level language programs that are nearly as efficient as programs
handwritten in assembly language. High-level language programmers often
get the mistaken impression that optimizing compilers will always generate
the best machine code possible, regardless of the source code the pro-
grammer gives them. This simply isn’t true. The statements and data
structures you choose in your source files can have a big impact on the
efficiency of the machine code a compiler generates. By teaching you how
to analyze the machine code your compiler generates, Thinking Low-Level,
Writing High-Level will teach you how to write efficient code without resorting
to assembly language.
There are many other attributes of great code besides efficiency, and the
third volume in this series, Engineering Software, will cover some of those.
Engineering Software will discuss how to create source code that is easily read
and maintained by other individuals and how to improve your productivity
without burdening you with the “busy work” that many software engineering
books discuss. Engineering Software will teach you how to write code that other
programmers will be happy to work with, rather than code that causes them
to use some choice words about your capabilities behind your back.
Great code works. Therefore, I would be remiss not to include a volume
on testing, debugging, and quality assurance. Whether you view software
testing with fear or with disgust, or you feel it’s something that only junior
engineers should get stuck doing, an almost universal truth is that few pro-
grammers properly test their code. This generally isn’t because programmers
actually find testing boring or beneath them, but because they simply don’t
know how to test their programs, eradicate defects, and ensure the quality
of their code. As a result, few applications receive high-quality testing, which
has led the world at large to have a very low opinion of the software engi-
neering profession. To help overcome this problem, the fourth volume in
No Starch Press, Copyright © 2004 by Randall Hyde
What You Need to Know to Write Great Code 3
this series, Testing, Debugging, and Quality Assurance, will describe how to
efficiently test your applications without all the drudgery engineers normally
associate with this task.
1.2 What This Volume Covers
In order to write great code, you need to know how to write efficient code,
and to write efficient code, you must understand how computer systems
execute programs and how abstractions found in programming languages
map to the low-level hardware capabilities of the machine. This first volume
teaches you the details of the underlying machine so you’ll know how
to write software that best uses the available hardware resources. While
efficiency is not the only attribute great code possesses, inefficient code
is never great. So if you’re not writing efficient code, you’re not writing
great code.
In the past, learning great coding techniques has required learning
assembly language. While this is not a bad approach, it is overkill. Learning
assembly language involves learning two related subjects: (1) machine
organization and (2) programming in assembly language. While learning
assembly language programming helps, the real benefits of learning
assembly language come from learning machine organization at the same
time. Few books have taught machine organization without also teaching
assembly language programming. To rectify this problem, this book teaches
machine organization independently of assembly language so you can learn
to write great code without the excessive overhead of learning assembly
language.
“So what is machine organization?” you’re probably wondering. Well,
machine organization is a subset of computer architecture, and this book
concentrates on those parts of computer architecture and machine organi-
zation that are visible to the programmer or are helpful for understanding
why system architects chose a particular system design. The goal of learning
machine organization is not to enable you to design your own CPU or
computer system, but to teach you how to make the most efficient use of
existing computer designs.
“Okay, so what is machine organization?” you’re probably still asking.
Well, a quick glance at the table of contents will give you an idea of what this
subject is all about. Let’s do a quick run-through of the book.
Chapters 2, 4, and 5 deal with basic computer data representation —
how computers represent signed and unsigned integer values, characters,
strings, character sets, real values, fractional values, and other numeric and
nonnumeric quantities. If you do not have a solid understanding of how
computers represent these various data types internally, it’s difficult to
understand why some operations that use these data types are so inefficient.
And if you don’t realize they’re inefficient, you’ll likely use them in an
inappropriate fashion and the resulting code will not be great.
No Starch Press, Copyright © 2004 by Randall Hyde
4 Chapter 1
Chapter 3 discusses binary arithmetic and bit operations used by most
modern computer systems. Because these operations are generally available
in programming languages, Chapter 3 also offers several insights into how
you can write better code by using arithmetic and logical operations in ways
not normally taught in beginning programming courses. Learning standard
“tricks” such as these is part of how you become a great programmer.
Chapter 6 begins a discussion of one of the more important topics in
this book: memory organization and access. Memory access is a common
performance bottleneck in modern computer applications. Chapter 6
provides an introduction to memory, discussing how the computer accesses
its memory, and describing the performance characteristics of memory.
This chapter also describes various machine code addressing modes that
CPUs use to access different types of data structures in memory. In modern
applications, poor performance often occurs because the programmer does
not understand the ramifications of memory access in their programs, and
Chapter 6 addresses many of these ramifications.
Chapter 7 returns to the discussion of data types and representation by
covering composite data types and memory objects. Unlike the earlier chap-
ters, Chapter 7 discusses higher-level data types like pointers, arrays, records,
structures, and unions. All too often programmers use large composite data
structures without even considering the memory and performance issues of
doing so. The low-level description of these high-level composite data types
will make clear their inherent costs enabling you to use them in your pro-
grams sparingly and wisely.
Chapter 8 discusses Boolean logic and digital design. This chapter pro-
vides the mathematical and logical background you’ll need to understand
the design of CPUs and other computer system components. Although this
particular chapter is more hardware oriented than the previous chapters,
there are still some good ideas that you can incorporate into really great code.
In particular, this chapter discusses how to optimize Boolean expressions,
such as those found in common high-level programming language state-
ments like
if, while, and so on.
Continuing the hardware discussion begun in Chapter 8, Chapter 9
discusses CPU architecture. Although the goal of this book is not to teach
you how to design your own CPU, a basic understanding of CPU design and
operation is absolutely necessary if you want to write great code. By writing
your code in a manner consistent with the way a CPU will execute that code,
you’ll get much better performance using fewer system resources. By writing
your applications at odds with the way CPUs execute code, you’ll wind up
with slower, resource-hogging programs.
Chapter 10 discusses CPU instruction set architecture. Machine instruc-
tions are the primitive units of execution on any CPU, and the time spent
during program execution is directly determined by the number and type
of machine instructions the CPU executes. Understanding how computer
architects design machine instructions can provide valuable insight into why
No Starch Press, Copyright © 2004 by Randall Hyde
剩余460页未读,继续阅读
Abopro
- 粉丝: 7
- 资源: 57
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Hadoop生态系统与MapReduce详解
- MDS系列三相整流桥模块技术规格与特性
- MFC编程:指针与句柄获取全面解析
- LM06:多模4G高速数据模块,支持GSM至TD-LTE
- 使用Gradle与Nexus构建私有仓库
- JAVA编程规范指南:命名规则与文件样式
- EMC VNX5500 存储系统日常维护指南
- 大数据驱动的互联网用户体验深度管理策略
- 改进型Booth算法:32位浮点阵列乘法器的高速设计与算法比较
- H3CNE网络认证重点知识整理
- Linux环境下MongoDB的详细安装教程
- 压缩文法的等价变换与多余规则删除
- BRMS入门指南:JBOSS安装与基础操作详解
- Win7环境下Android开发环境配置全攻略
- SHT10 C语言程序与LCD1602显示实例及精度校准
- 反垃圾邮件技术:现状与前景
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功