博客 / 詳情

返回

《編譯原理》閲讀筆記:p18

《編譯原理》學習第 3 天,p18總結,總計 14頁。

一、技術總結

1.assembler

(1)計算機結構

要想學習彙編的時候更好的理解,要先了解計算機的結構,以下是本人學習彙編時總結的一張圖,每當學習彙編時,看到“計數器”,“解碼器”,“寄存器”,“數據總線”等概念時,就知道説的這些東西在哪個位置。

(2)assembly code(彙編代碼)

p17,Some compilers produce assembly code, as in (1.5), that is passed to an assembler for further processing.

MOVF id3, R2
MULF #60.0, R2
MOVF id2, R1
ADDF R2, R1
MOVF R1,id1

上面彙編代碼對應的代碼為:

temp1 := id3 * 60.0
id1: = id2 + temp1

這裏提到了彙編代碼,所以我們在閲讀本書時需要有一點彙編語言基礎:

(3)指令(instruction)

如MOVF, F表示Floating-point numbers。注意,指令有兩種語法,分別是Intel 語法和AT&T語法。支持Intel語法的主要是Windows系統,支持AT&T語法的主要是Unix系統。

Intel 語法:mov dest, src

AT&T 語法:mov src, dest

參考:https://en.wikipedia.org/wiki/X86_assembly_language

p15, The first and second operands of each instruction specify a source and destination, respectively....This code moves the contents of address id3 into register2, then multiplies it with the real-constant 60.0.——書裏使用的是AT&T語法,本書作者之一Alfred V.Aho與AT&T的關係:Alfred V.Aho is head of the Computation Principle Research Department at AT&T Bell Laboratories in Murray Hill New Jersey。

(4)#號

表示intermediate data。

2.machine code

0001 01 00 00000000 
0011 01 10 00000010
0010 01 00 00000100 

如上所示稱為machine code, 當我們看到“machine code”這個詞的時候我們要想到上面的代碼。

二、其它

進入六月以來,每天都忙於加班,疲於奔命,閲讀《編譯原理》幾乎無進度,然而內心覺得這並不是我想要的,因為長此以往,就會停不前,還是要每天學習一些新的東西;二是,自己也不喜歡這樣重複的去做相同的事。所以,我又折回來繼續看書了。

四、參考資料

1. 編程

(1)Alfred V. Aho,Monica S. Lam,Ravi Sethi,Jeffrey D. Ullman,《編譯原理(英文版·第1版)》:https://book.douban.com/subject/5416783/

2. 英語

(1)Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

歡迎搜索及關注:編程人(a_codists)

user avatar xiaopaipiper 頭像 jianhuan 頭像 phytium_developers 頭像
3 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.