【正文】
an expert well versed in both types of programming languages or someone who has never taken the time to learn assembly language and develop an honest opinion of its capabilities? In a conversation with someone, I would go to great lengths to address each of the above , in a rough draft of this chapter I spent about ten pages explaining what is wrong with each of the above statements. However, this book is long enough and I felt that very little was gained by going on and on about these points. Noheless, a brief rebuttal to each of the above points is in order, if for no other reason than to keep you from thinking there isn39。t have much experience debugging assembly language programs, it39。s why you use C 4 pilers. Today, machines are so fast that we no longer need to use assembly. It is amazing that people will spend lots of money to buy a machine slightly faster than the one they own, but they won39。t impress those who know the truth. 2 What39。ve got lots to do. My time would be better spent writing code than learning assembly language. There are some practical reasons for learning assembly, even if you never intend to write a single line of assembly code. If you know assembly language well, you39。下面是人 們 所 給 出的若干 條不 使用 匯編語 言的理由: ( 1) 匯編語言學(xué) 起 來 很困 難; ( 2) 閱讀 和理解 匯編 程序很困 難; ( 3) 調(diào)試匯編 程序很困 難; ( 4) 匯編 程序 難維護 ; ( 5) 編寫匯編 程序很困 難; ( 6) 編寫匯編 程序很耗 費時間; ( 7)日益改 進 的 編譯 技 術(shù) 使得 匯編語 言已不再重要; ( 8)目前 計 算機的 運 行速度已 經(jīng)足夠 快了,再去使用 匯編語 言已 顯得 多余; ( 9)如果你想要追求更快的 計 算機 運 行速度,你 應(yīng)該 去使用一 個 更高效的算法而不是 轉(zhuǎn) 向 去借助 于匯編語 言; ( 10)目前 計 算機的 內(nèi) 存容量已 經(jīng)足夠 大了,通 過 使用 匯編語 言 來達到節(jié)省 內(nèi) 存的 這 種做法已不再可?。? ( 11) 匯編語 言依 賴于 具體的機器硬件 環(huán) 境,不具 備 良好的移植性。 匯編語言學(xué) 起 來 很困 難 。但是那些 持有這 種 觀點 的大多 數(shù) 人并不真正了解 匯編語 言,如果你胡 亂寫 出一 個匯編 程序,那肯定是 讓 人 無 法 閱讀 和理解。但是能 編寫 出一 個 高 質(zhì) 量的, 好維護 的程序的人并不能 稱 之 為 天才。 編寫匯編 程序很耗 費時間 。 不僅 如此,你也很少 會 遇到一位愿意做 將 C 程序代 碼轉(zhuǎn)換 成等價的 匯編 代 碼 工 作的匯編程序 員 ,也 許 , 這 也就是那些 反對 使用 匯編語 言的 人為 什么用 C 編譯 器的原因了吧。在 過 去很 長 一段 時間 里,程序 員們 所使用機器的 內(nèi) 存容量都是4KB,后 來 , 隨著機 器的 內(nèi) 存容量 擴 展 為 32KB 或者 64KB,程序 員們所編寫 出 來的程序的大小也 隨 之增 長 。 可移植性差可能是人 們反對 使用 匯編語 言最主要的原因了。 ( 2)空 間 匯編 程序往往是最 簡 潔的。 節(jié) 省 內(nèi) 存空 間 就意味 著 省 錢 , 這個道理相 當(dāng)簡單 易懂。一 個 可以很好的 說 明 問題的 例子就是在 匯編語 言直接支持 對 機器各種硬件的 訪問與 操作,并且 有許 多相 應(yīng) 的指令可 進 行具體 實 施,而像 C 這樣 的高 級語 言就不能如此。但是一旦你掌握了 匯編語 言,你就 會發(fā)現(xiàn) 你已 經(jīng) 離不 開它 了。一 個匯編 程序 員 一般均勝 過 一名高 級語 言程序 員 ,因 為 他 們 知道 編譯 器的局限之 處 并且知道 編譯器在編譯時 是怎 樣處 理他們 程序中的代 碼的 。使用高 級語言編寫 出的程序 獨 立于具體的機器硬件 環(huán) 境,它 們 很少考 慮 一臺機器的具體特 點 。 盡 管一些人 認(rèn)為 程序 員 可以不用 擔(dān)心計 算機 內(nèi) 存容量的限制,但是 我們 仍然需要程序 員去編寫 一些 簡 潔的程序。如果你 對 機器的 運 行速度最 為關(guān) 心的 話 ,那么即使十 分討厭匯編語 言的人也不得不承 認(rèn),匯編語 言是一 個 不 錯 的 選擇 。但是用 C 語言編寫 的程序也并不能保 證 具有良好的移植性。 目前 計 算機的 內(nèi) 存容量已 經(jīng)足夠 大了,通 過 使用 匯編語 言 來達到節(jié) 省 內(nèi) 存的 這 種做法已不再可取。 針對編譯 器的優(yōu)化研究正在日益取得 進 展,然而 對 于同一 問題匯編 程序 員所編寫 出的代 碼和 使用高 級語言編寫 并 經(jīng)過編譯 器翻 譯 后所生成的 匯編 代 碼還 是有所不同。 這 些 標(biāo) 準(zhǔn)函 數(shù)庫 中的函 數(shù) 能 夠用來 解 決許 多 實際編 程 問題,而匯編 程序 員卻沒 有 現(xiàn) 成的 標(biāo) 準(zhǔn)函 數(shù)庫 可供利用,只有完全通 過 自己 來編寫程 序。 實際 上, C 語 言程序也 難維護 ,想要使程序 運 行相 當(dāng)長 9 的一段 時間 而不出 現(xiàn) 任何 問題 相 當(dāng) 困 難 。 閱讀 和理解 匯編 程序很困 難 。那么, 誰又會 相信,一 個 精通多種 編 程 語 言但 卻沒 有花 時間去學(xué)習(xí)匯編語 言的人能 夠 形成 對匯編語 言如 實 、客 觀 的 評 價呢? 當(dāng) 我和 別 人交 談時 ,我 會盡 可能的表 達 出我的以上 觀點 ,在本章的前言中 ,我準(zhǔn) 備花十頁紙 去逐 個解釋 前面列出的每一種 觀點 , 盡管這 本 書 已 經(jīng)夠長 了,但是 對前 面列出的 這 些 觀點進 行 簡 明扼要的反 駁還 是有必要的。ll probably start using it far more than you ever dreamed you would. That is a mon malady among assembly language programmers. Seems they can39。t a particularly attractive solution either. With virtual memory, the bigger an application is, the slower the system will run as a result of that program39。t pile and run on a Macintosh. And even if they did, most Mac owners wouldn39。t true and probably never will be true. Optimizing pilers are getting better every day. However, assembly language programmers get better performance by writing their code differently than they would if they were using some HLL. If assembly language programmers wrote their programs in C and then translated them manually into assembly, a good C piler would produce equivalent, or even better, code. Those who make this claim about piler technology are paring their handpiled code against that produced by a piler. Compilers do a much better job of piling than humans. Then again, you39。s very easy to write impossibletoread assembly langu