> For the complete documentation index, see [llms.txt](https://koshizuow.gitbook.io/compilerbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koshizuow.gitbook.io/compilerbook/machine_code_assembler/matome.md).

# 本章小結

本章對於電腦內部如何運作、還有C編譯器該做什麼的概要，做了一個大略的說明。機械語言或組合語言，雖然看起來和C語言差很多、很像一團雜亂的資料，但認為其意外地忠實地反映了C語言架構的讀者應該也不少吧。

本書對 CPU 指令幾乎都還沒有說明，讀者對`objdump`輸出的組合語言到底具有什麼樣的意義，可能還不是很清楚，但是應該可以想像每個指令並沒有做太複雜的事情。在本章只要有掌握到這樣的感覺就夠了。

本章摘要如下：

* CPU 是一邊讀寫記憶體讓程式進行下去的。
* CPU 實行的程式、程式所處理的資料，都是放在記憶體中。CPU 逐行讀取機械碼指令，然後執行其所代表的指令。
* CPU 有名為暫存器的小容量存取空間，多數的 CPU 指令是定義成在暫存器之間進行操作的。
* 組合語言是對人類來說較可讀的機械語言，C編譯器一般多是輸出組合語言。
* C語言的函式在組合語言也是一個函式。
* 函式的呼叫是用堆疊實作的。

{% hint style="info" %}

#### 小知識：線上編譯器

看C程式編譯結果來學習組合語言是一個不錯的方法，但是多次修改程式碼、編譯、確認結果這個過程，比想像中要麻煩許多。有一個很棒的網頁可以省去這個麻煩，那就是 [Compiler Explorer](https://godbolt.org/z/RyNqgE)（通稱 godbolt）。在 Compiler Explorer 左半邊的文字框輸入程式碼後，右半邊就會即時出現編譯過的組合語言指令。想要確認C程式碼會變成什麼樣的組合語言指令時，用這個網站會是一個很好的選項。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://koshizuow.gitbook.io/compilerbook/machine_code_assembler/matome.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
