Introduction: "Why Would You Want to Do That?"
It was 1985, and I was in a chartered bus in New York City, heading for a press reception with a bunch
of other restless media egomaniacs. I was only beginning my media career (as technical editor for PC
Tech Journal) and my first book was still months in the future. I happened to be sitting next to an
established programming writer/guru, with whom I was impressed and to whom I was babbling about
one thing or another. I won't name him, as he's done a lot for the field, and will do a lot more before
he's through if he doesn't kill himself smoking first.
But I happened to let slip that I was a Turbo Pascal fanatic, and what I really wanted to do was learn
how to write Turbo Pascal programs that made use of the brand new Microsoft Windows user interface.
He wrinkled his nose and grimaced wryly, before speaking the Infamous Question:
"Why would you want to do that?"
I had never heard the question before (though I would hear it many times thereafter), and it took me
aback. Why? Because, well, because…I wanted to know how it worked.
"Heh. That's what C's for."
Further discussion got me nowhere in a Pascal direction. But some probing led me to understand that
you couldn't write Windows apps in Turbo Pascal. It was impossible. Or...the programming writer/guru
didn't know how. Maybe both. I never learned the truth. But I did learn the meaning of the Infamous
Question.
Note well: When somebody asks you, "Why would you want to do that?" what it really means is this:
"You've asked me how to do something that is either impossible using tools that I favor or completely
outside my experience, but I don't want to lose face by admitting it. So,...how 'bout those Blackhawks?"
I heard it again and again over the years:
Q: How can I set up a C string so that I can read its length without scanning it?
A: Why would you want to do that?
Q: How can I write an assembly language subroutine callable from Turbo Pascal?
A: Why would you want to do that?
Q: How can I write Windows apps in assembly language?
A: Why would you want to do that?
You get the idea. The answer to the Infamous Question is always the same, and if the weasels ever
ask it of you, snap back as quickly as possible: Because I want to know how it works.
That is a completely sufficient answer. It's the answer I've used every single time, except for one
occasion a considerable number of years ago, when I put forth that I wanted to write a book that taught
people how to program in assembly language as their first experience in programming.
Q: Good grief, why would you want to do that?
A: Because it's the best way there is to build the skills required to understand how all the rest of the
programming universe works.
Being a programmer is one thing above all else: It is understanding how things work. Learning to be a
programmer, furthermore, is almost entirely a process of learning how things work. This can be done at
various levels, depending on the tools you're working with. If you're programming in Visual Basic, you
have to understand how certain things work, but those things are by and large confined to Visual Basic
itself. A great deal of machinery is hidden by the layer that Visual Basic places between the
programmer and the computer. (The same is true of Delphi, Java, Perl, and many other very high-level
programming environments.) If you're using a C compiler, you're a lot closer to the machine, and you
see a lot more of that machinery-and must, therefore, understand how it works to be able to use it.
However, quite a bit remains hidden, even from the hardened C programmer. (Many C programmers
fool themselves into thinking they know way more than they actually do-and have the bad karma to be
pretty damned arrogant about it.)
If, on the other hand, you're working in assembly language, you're as close to the machine as you can
get. Assembly language hides nothing, and withholds no power. The flip side, of course, is that no
magical layer between you and the machine will absolve any ignorance and take care of things for you.
If you don't understand how something works, you're dead in the water-unless you know enough to be
able to figure it out on your own.
That's a key point: My goal in creating this book is not entirely to teach you assembly language per se.
If this book has a prime directive at all, it is to impart a certain disciplined curiosity about the machine,
along with some basic context from which you can begin to explore the machine at its lowest levels.
That, and the confidence to give it your best shot. This is difficult stuff, but it's nothing you can't master
given some concentration, patience, and the time it requires-which, I caution, may be considerable.
In truth, what I'm really teaching you is how to learn.
这是Jeff Duntemannd 在《Assembly Language Step-by-Step: Programming with DOS and Linux, Second Edition》中的一章的内容。
呵呵,我好象也常常问这样的问题,看来我也是真的不好意思承认自己的无知、、、
只有几次例外,如一个同事用了多个消息循环,另一个却喜欢在程序中create table与drop table、、、呵呵