Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
第 6 章、巨集處理器
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
陳鍾誠
June 08, 2022
Education
0
120
第 6 章、巨集處理器
陳鍾誠
June 08, 2022
Tweet
Share
More Decks by 陳鍾誠
See All by 陳鍾誠
第 7 章、高階語言
ccckmit
0
190
第 9 章、虛擬機器
ccckmit
0
120
第 8 章、編譯器
ccckmit
0
240
數學、程式和機器
ccckmit
2
820
語言處理技術
ccckmit
0
200
微積分
ccckmit
1
510
系統程式 第 1 章 -- 系統軟體
ccckmit
0
560
系統程式 第 2 章 -- 電腦的硬體結構
ccckmit
0
550
系統程式 第 3 章 -- 組合語言
ccckmit
0
430
Other Decks in Education
See All in Education
タイムマシンのつくりかた
nomizone
2
1k
東大1年生にJulia教えてみた
matsui_528
7
12k
環境・社会理工学院(建築学系)大学院説明会 2026|東京科学大学(Science Tokyo)
sciencetokyo
PRO
0
280
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
1125
cbtlibrary
0
190
高校数学B「統計的な推測」 分野の問題と課題
shimizudan
1
110
Avoin jakaminen ja Creative Commons -lisenssit
matleenalaakso
0
2.1k
資格支援制度-株式会社HIT
kabushikigaisya_hit
0
320
2025年の本当に大事なAI動向まとめ
frievea
1
190
【ベテランCTOからのメッセージ】AIとか組織とかキャリアとか気になることはあるけどさ、個人の技術力から目を背けないでやっていきましょうよ
netmarkjp
2
3.8k
Postcards
gabrielramirezv
0
160
HCI Research Methods - Lecture 7 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.4k
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
170
Making Projects Easy
brettharned
120
6.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
130
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
190
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
130
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
230
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
96
Ethics towards AI in product and experience design
skipperchong
2
210
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Transcript
第 6 章、巨集處理器 作者:陳鍾誠 旗標出版社
第 6 章、巨集處理器 6.1 組合語言的巨集 6.2 巨集處理的演算法
6.3 實務案例:C 語言的巨集
簡介:巨集處理器 巨集處理器 (Macro Processor) 乃是一種方便程式 撰寫者使用, 避免重複撰寫程式的工具 在程式被編譯前,
巨集處理器會先將程式當中的巨 集展開, 然後再交給編譯器或組譯器進一步處理。
6.1 組合語言的巨集
巨集處理器的動作 巨集展開 將巨集的內容嵌入到呼叫行上,並整個展開 參數取代 將巨集參數取代為呼叫參數
標記編號 為標記加上編號, 以避免重複的狀況。
6.2 巨集處理的演算法 通常分為兩輪 (2-Pass) 進行處理 第一輪:定義巨集 將巨集內容儲存到記憶體表格中。
第二輪:展開巨集 在呼叫時展開巨集,並進行參數取代與標記編號等動 作。
單層巨集處 理器的演算 法
6.3 實務案例:C 語言的巨集 在 C 語言的設計中, 有兩種巨集宣告方式 方式一:
使用 #define 指令宣告巨集函數 方式二: 利用 inline 指令, 讓一般函數改為巨集函數 方式一較為常用,本節將以#define為例
C 語言的巨集展開 使用 gcc 加上 –E 參數,可以將巨集展開
條件式展開 不加 DEBUG:gcc -E macroDebug.c -o MacroDebug_E.c 有加
DEBUG:gcc -E -D_DEBUG_ macroDebug.c -o MacroDebug_DEBUG_E.c
習題 6.1 請說明巨集處理器的輸入、輸出與功能為何? 6.2 請說明巨集處理器會如何處理巨集參數? 6.3 請說明巨集處理器在展開標記時會產生甚麼問題,
應如何解決? 6.4 請使用 gcc 工具將範例 6.2 展開, 觀察展開後的檔 案, 並說明展開前後的對應關係。 6.5 請使用 gcc 工具將範例 6.3 展開, 觀察展開後的檔 案, 並說明展開前後的對應關係