【正文】
不 過這 是所有 匯編 程序 員 的一 個 普遍的缺 點 ,因為 他 們 看上去 實 在不能忍受 編譯 器拙劣的 編譯 工作。首先,如果你很了解 匯編語 言的 話 ,你就 會對編譯 器有了一 個 更深刻的 認(rèn)識 ,并且 會 確切地知道 編譯器在編譯時 是如何 將 程序中的 語 句翻 譯 成機器代 碼的 。因此可以 說 ,使用 匯編語 言可以 進(jìn) 行最底 層的 機器硬件 編 程,而 這 一特 點卻 是如今 許 多高 級語 言所不具 備 的。 能力是人 們 使用 匯編語 言的另一 個 理由。如果一 個程 序有 ,那么 這個程 序 就無 法存 儲 在一 張 的 軟盤 中;同 樣 地,如果一 個應(yīng) 用程序需要 2MB 的 內(nèi) 存空 間 ,而 計 算機中只有1M 的 內(nèi) 存空 間 ,那么 該 用 戶 就不得不去再安 裝 一 條 1M 的 內(nèi) 存 條 。甚至即使你的程序不通 過編譯 器的優(yōu)化, 將 程序的 運 行速度 進(jìn)行大幅提升也是可能的。 ( 3)能力 我們 能 夠用匯編語言編寫 出一些在高 級語 言中很困 難 或者根本無 法 實現(xiàn) 的程序。 11 言的 優(yōu)勢 是什么 有一 個 古老的 笑話 是 這樣說 的:使用 匯編語 言有三 個 理由,那就是速度、速度、更快的速度。但是那些因 為匯編語 言可移植性差而拒 絕 使用 該語 言的人 卻轉(zhuǎn)向 去使用移植性同 樣 很差的 C語 言。如果你需要 將你所編寫的匯編 程 序能在不同的 計 算機上 運 行,那么 你在編寫匯編 代 碼時 需要花 費 很多的心思。如今, 許 多 計 算 機的 內(nèi) 存容量已 經(jīng) 是 32M 或是 64M了,而程序 員們所編寫 出的程序大小更是 繼續(xù) 增 長 ,有的程序甚至在 運 行 時 需要占用整 個內(nèi) 存空 間 。 其實 ,上 述觀點并 不正確, 難道匯編語 言中就 沒 有一些高效的算法 了嗎 ?在任何高 級語 言中能 夠 使用的算法就一定能 夠在匯編語言中使用;但是 卻有許 多能在 匯編語 言中使用的算法不能在高 級語 言中使用。 目前 計 算機的 運 行速度已 經(jīng)足夠 快了,再去使用 匯編語 言已 顯得 多余。首先, 這 種 觀點是錯誤的而且 很可能 永遠(yuǎn) 是 這樣 。 軟 件工 程師們估計 , 軟件開發(fā)者 在一 個軟件開發(fā) 周期 中僅僅 花 費 大 約 30%的 時間來編寫代碼, 即 使軟件開發(fā)者 用 匯編語 言花了比使用一些高 級語 言 兩 倍的 時間來編寫代碼, 其 對 整 個軟 件 項目 完成 時間 的影 響也 只有 15%的不同。然而,像 C 語 言, Ada 語 言和 Modual2 語 言的程序 員卻 一直享 受著其語 言中的 標(biāo) 準(zhǔn)函 數(shù)庫給編 程 帶來 的便利。 這 種技能 實際 上可以通 過 不 斷 的 積 累 編程經(jīng)驗 而 獲 得。 匯編 程序 難維護(hù) 。 實際 上 ,匯編 語 言和 其它語言一 樣 也是很好 學(xué)習(xí) 的。同 樣 ,因 為匯編語 言跟 Pascal 語 言有很大的不同,所以 學(xué)習(xí) 起 匯編語 言 來 要比 你學(xué)習(xí)起和 Pascal 很相似的那些 語 言 難 度大了很多,不 過 我相信 學(xué)習(xí)匯編語 言 應(yīng)該 要比你第一次 學(xué)習(xí) 起 編 程 語 言 時 要 輕 松一些。 不僅 是 學(xué)習(xí)匯編語 言如此, 當(dāng)你學(xué)習(xí) 起 一門 不熟悉的程序 設(shè)計語 言 時 ,情 況 也是如此。 匯編語 言的使用者也使用一些高 級語 言,而那些 對匯編語 言的 反對者卻 很少使用 匯編語 言。 假如 這 是一本 為 具有大 學(xué) 水平的 讀 者 編寫的匯編 程序 設(shè)計 的教材,并且看上去 該書 作者的 寫 作意 圖明 確,因此作 為 一名 讀 者,你 會 自然而然地去相信 書 中所 寫 的 內(nèi) 容, 讀 者 們 , 當(dāng) 你 們讀到這 里的 時 候,你 們 肯定 會開始去猜測 到 匯編語言一定 有許 多不 盡 如人意的地方了。t know assembly language will accept the poor performance their piler produces and simply shrug it off. Yes, assembly language is definitely worth the effort. The only scary thing is that once you learn it really well, you39。ll have an appreciation for the piler, and you39。t excusable. Most users put more than eight megabytes in their machines so they can run multiple programs from memory at one time. The bigger a program is, the fewer applications will be able to coexist in memory with it. Virtual memory isn39。s Right With Assembly Language? An old joke goes something like this: There are three reasons for using assembly language: speed, speed, and more speed. Even those who absolutely hate assembly language will admit that if 5 speed is your primary concern, assembly language is the way to go. Assembly language has several benefits: ( 1) Speed. Assembly language programs are generally the fastest programs around. ( 2) Space. Assembly language programs are often the smallest. ( 3) Capability. You can do things in assembly which are difficult or impossible in HLLs. ( 4) Knowledge. Your knowledge of assembly language will help you write better programs, even when using HLLs. Assembly language is the uncontested speed champion among programming languages. An expert assembly language programmer will almost always produce a faster program than an expert C programmer. While certain programs may not benefit much from implementation in assembly, you can speed up many programs by a factor of five or ten over their HLL counterparts by careful coding in assembly language。ll have to think long and hard about using assembly language. Using C (or some other HLL) is no guarantee that your program will be portable. C programs written for the IBM PC won39。t spend any extra time writing their code in assembly so it runs faster on the same hardware. There are many raging debates about the speed of machines versus the speed of the software, but one fact remains: users always want more speed. On any given machine, the fastest possible programs will be written in assembly language. If you need more speed, you should use a better algorithm rather than switch to assembly language. Why can39。 however, the savings is insufficient to counter the benefits of using assembly language. Improved piler technology has eliminated the need for assembly language. This isn39。s going to be hard to debug them. Remember what it was l