Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
第 6 章、巨集處理器
Search
陳鍾誠
June 08, 2022
Education
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
第 6 章、巨集處理器
陳鍾誠
June 08, 2022
More Decks by 陳鍾誠
See All by 陳鍾誠
第 7 章、高階語言
ccckmit
0
280
第 9 章、虛擬機器
ccckmit
0
200
第 8 章、編譯器
ccckmit
0
340
數學、程式和機器
ccckmit
2
940
語言處理技術
ccckmit
0
300
微積分
ccckmit
1
640
系統程式 第 1 章 -- 系統軟體
ccckmit
0
670
系統程式 第 2 章 -- 電腦的硬體結構
ccckmit
0
650
系統程式 第 3 章 -- 組合語言
ccckmit
0
550
Other Decks in Education
See All in Education
BRIEF OUTLINE OF IMPORTANT PLANT CONSTITUENTS
pawan_pharm
0
230
パラグラフから始めるアカデミック・ライティング
neuroiwm
3
2.5k
新型コロナ禍をともに「楽しみながら開いていこう!」 :中門 吉松 会員(2720 Japan O.K.ロータリーEクラブ)卓話 : 2026.10.19.例会・卓話
2720japanoke
0
680
DecisionesEjecutivasCrisis
mariooc
0
430
【ホスト用】ainiチャット操作ガイド
ainischool
0
130
El Clima de España. Tema 2 (PPT)
juanmartin2026
0
19k
AI活用の基礎体験ハンズオン(松尾研 AXエバンジェリスト講座)
minorun365
PRO
11
13k
2026年度秋学期 統計学 第1回 イントロダクション ー 統計的なものの見方・考え方について (2026. 9. 29)
akiraasano
PRO
0
270
Introduction - Lecture 1 - Web Technologies (1019888BNR)
signer
PRO
0
6.6k
Before You Scale: Understand the Theory Behind the Simulation
pfn
PRO
1
110
One Year of Learning English with AI @エンジニア英語キャリア Meetup #3
kekekenta
0
330
Science Tokyo University for International Research Excellence scheme_April 2026
sciencetokyo
PRO
0
670
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
940
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
510
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Optimising Largest Contentful Paint
csswizardry
37
4k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Building the Perfect Custom Keyboard
takai
2
920
How to build a perfect <img>
jonoalderson
1
6.2k
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 展開, 觀察展開後的檔 案, 並說明展開前後的對應關係