Skip to content

Commit 64ec025

Browse files
committed
upload a 0906 log of Computer Construction :Compiler-lever code
1 parent b0728ba commit 64ec025

File tree

505 files changed

+12318
-5263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

505 files changed

+12318
-5263
lines changed

content/posts/0906.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
+++
2+
date = '2025-09-07T23:32:42+08:00'
3+
draft = false
4+
title = '0906学习日志'
5+
6+
categories="log"
7+
8+
tags=["计算机组成原理","指令系统","RISC","CISC","程序的机器级代码表示","汇编语言","常用指令"]
9+
10+
+++
11+
12+
## 计算机组成原理-死去的RISC-V突然攻击我
13+
14+
### 程序的机器级代码表示
15+
16+
1. 常用汇编指令介绍
17+
18+
1. 相关寄存器
19+
20+
| 16bit | 32bit | 说明 |
21+
| ----- | ----- | --------------------------- |
22+
| AX | EAX | 累加器(Accumulator) |
23+
| BX | EBX | 基地址寄存器(Base Register) |
24+
| CX | ECX | 计数寄存器(Count Register) |
25+
| DX | EDX | 数据寄存器(Data Register) |
26+
| | ESI | 变址寄存器(Index Register) |
27+
| | EDI | 变址寄存器(Index Register) |
28+
| | EBP | 堆栈基指针(Base Pointer) |
29+
| | ESP | 堆栈顶指针(Stack Pointer) |
30+
31+
2. 汇编指令格式
32+
33+
1. AT&T 格式简介
34+
35+
- 主要用于 **GNU Assembler (GAS)**,即 `gcc` 默认输出。
36+
37+
- 语法较“繁琐”,但严格、明确,容易让编译器处理。
38+
39+
- 特点:寄存器有 `%` 前缀,立即数 `$` 前缀,操作数顺序是 `源, 目的`
40+
41+
示例:
42+
43+
```asm
44+
movl $5, %eax # 把立即数 5 移动到 eax
45+
addl %eax, %ebx # ebx = ebx + eax
46+
movl 8(%ebp), %ecx # 从 [ebp+8] 取数到 ecx
47+
```
48+
49+
2. Intel 格式简介
50+
51+
- 常见于 **MASM / NASM / Windows 平台**。
52+
53+
- 更接近高级语言风格,简洁直观,广泛用于手写汇编和逆向分析。
54+
55+
- 特点:操作数顺序 `目的, 源`,寄存器无 `%`,立即数直接写,内存寻址用 `[]`。
56+
57+
示例:
58+
59+
```asm
60+
mov eax, 5 ; 把立即数 5 移动到 eax
61+
add ebx, eax ; ebx = ebx + eax
62+
mov ecx, [ebp+8] ; 从 [ebp+8] 取数到 ecx
63+
```
64+
65+
66+
67+
3. 对比表:AT&T vs Intel 汇编格式
68+
69+
| 特点 | **AT&T 格式** | **Intel 格式** |
70+
| -------------- | --------------------------------------------------- | ------------------------------------------------------- |
71+
| **操作数顺序** | 源, 目的 | 目的, 源 |
72+
| **寄存器** | `%eax`、`%ebx` | `eax`、`ebx` |
73+
| **立即数** | `$5` | `5` |
74+
| **内存寻址** | `disp(base, index, scale)` → `8(%ebp, %ecx, 4)` | `[base + index*scale + disp]` → `[ebp + ecx*4 + 8]` |
75+
| **操作数大小** | 指令后缀:`b`=8位, `w`=16位, `l`=32位, `q`=64位 | `byte ptr`, `word ptr`, `dword ptr`, `qword ptr` |
76+
| **符号/变量** | `movl $var, %eax` (取地址) `movl var, %eax` (取值) | `mov eax, offset var` (取地址) `mov eax, [var]` (取值) |
77+
| **汇编器** | GNU Assembler (`gas`) | MASM, NASM, FASM 等 |
78+
| **常见平台** | Linux/Unix 系统 | Windows、逆向工程 |
79+
80+
3. 常用指令
81+
82+
* <reg>
83+
* <mem>
84+
* <con>,<con32>
85+
86+
1. 数据传送指令
87+
1. mov
88+
2. push
89+
3. pop
90+
2. 算术和逻辑运算指令
91+
1. add/sub
92+
2. inc/dec
93+
3. imul
94+
4. idiv
95+
5. and/or/xor
96+
6. not
97+
7. neg
98+
8. shl/shr
99+
3. 控制流指令
100+
1. jmp
101+
2. jcondition: je,jz,jne,jg,jge,jl,jle
102+
3. cmp/test
103+
4. call/ret
104+
105+
2. 选择语句的机器级表示
106+
107+
```pseudocode
108+
if(test_expr)
109+
then_statement
110+
else
111+
else_statement
112+
```
113+
114+
```pseudocode
115+
t=test_expr
116+
if(!t)
117+
goto false;
118+
then_statement
119+
goto done;
120+
false:
121+
else_statement
122+
done;
123+
```
124+
125+
3. 循环语句的机器级表示
126+
127+
1. do-while
128+
129+
```pseudocode
130+
do
131+
body_statement
132+
while(test_expr);
133+
```
134+
135+
```pseudocode
136+
loop:
137+
body_statement
138+
t=test_expr;
139+
if(t)
140+
goto loop;
141+
```
142+
143+
2. while
144+
145+
```pseudocode
146+
while(test_expr)
147+
body_statement
148+
```
149+
150+
```pseudocode
151+
t=test_expr;
152+
if(!t)
153+
goto done;
154+
loop:
155+
body_statement;
156+
t=test_expr;
157+
if(t)
158+
goto loop;
159+
done:
160+
```
161+
162+
3. for
163+
164+
```pseudocode
165+
for(init_expr;test_expr;update_expr)
166+
body_statement
167+
```
168+
169+
```pseudocode
170+
init_expr;
171+
t=test_expr;
172+
if(!t)
173+
goto done;
174+
loop:
175+
body_statement
176+
update_expr;
177+
t=test_expr;
178+
if(t)
179+
goto loop;
180+
done:
181+
```
182+
183+
4. 过程调用的机器级表示
184+
185+
------
186+
187+
188+
189+
### CISC和RISC的基本概念
190+
191+
1. 复杂指令系统计算机(CISC)
192+
193+
- 特点:指令集复杂,每条指令可以完成较复杂的操作,指令长度不固定。
194+
- 设计理念:**软件简单化,把更多功能交给硬件来完成**。
195+
- 常见架构:x86、VAX、68000。
196+
197+
2. 精简指令系统计算机(RISC)
198+
199+
- 特点:指令集简单,每条指令长度固定,执行时间大多相同。
200+
- 设计理念:**硬件简单化,指令执行快,依靠编译器优化来实现复杂功能**。
201+
- 常见架构:ARM、MIPS、RISC-V、SPARC。
202+
203+
3. CISC和RISC的比较
204+
205+
| 特点 | **RISC**(精简指令集) | **CISC**(复杂指令集) |
206+
| ---------------- | -------------------------- | -------------------------- |
207+
| **指令数量** | 少,指令集精简 | 多,指令功能复杂 |
208+
| **指令长度** | 固定(常见 32 位) | 不固定(8~120 字节不等) |
209+
| **指令执行时间** | 大多数指令 1 个时钟周期 | 指令执行时间差别大 |
210+
| **寻址方式** | 少(常 3~5 种) | 多(十几种甚至几十种) |
211+
| **硬件复杂度** | 控制器一般为硬布线(简单) | 控制器常为微程序(复杂) |
212+
| **编译器依赖性** | 高,复杂操作要由编译器分解 | 低,硬件可直接完成复杂操作 |
213+
| **性能优化方式** | 通过流水线、寄存器优化 | 通过复杂指令减少代码长度 |
214+
| **代表架构** | ARM、MIPS、RISC-V | x86、Intel 8086、VAX |
215+
| **代码密度** | 代码长(指令多) | 代码短(指令少,但复杂) |
216+
217+
218+

content/posts/0907.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
date = '2025-09-07T23:32:48+08:00'
3+
draft = true
4+
title = '0907'
5+
+++

public/404.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="zh-cn" dir="ltr">
3-
<head><script src="/npee_learning_log.github.io/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=npee_learning_log.github.io/livereload" data-no-instant defer></script><meta charset='utf-8'>
3+
<head><meta charset='utf-8'>
44
<meta name='viewport' content='width=device-width, initial-scale=1'><meta name='description' content="無職受験生 ~408に挑んだら本気だす~">
55
<title>404 Page not found</title>
66

7-
<link rel='canonical' href='http://localhost:1313/npee_learning_log.github.io/404.html'>
7+
<link rel='canonical' href='https://auroraemiya.github.io/npee_learning_log.github.io/404.html'>
88

99
<link rel="stylesheet" href="/npee_learning_log.github.io/scss/style.min.cfa5b1b0e78d61c00a14173992a1f3fa3b5c1b9fa34d023de959af564e7b19dd.css"><meta property='og:title' content="404 Page not found">
1010
<meta property='og:description' content="無職受験生 ~408に挑んだら本気だす~">
11-
<meta property='og:url' content='http://localhost:1313/npee_learning_log.github.io/404.html'>
11+
<meta property='og:url' content='https://auroraemiya.github.io/npee_learning_log.github.io/404.html'>
1212
<meta property='og:site_name' content='shyの考研日志'>
13-
<meta property='og:type' content='website'><meta property='og:updated_time' content=' 2025-09-06T12:18:02&#43;08:00 '/>
13+
<meta property='og:type' content='website'><meta property='og:updated_time' content=' 2025-09-07T23:32:48&#43;08:00 '/>
1414
<meta name="twitter:title" content="404 Page not found">
1515
<meta name="twitter:description" content="無職受験生 ~408に挑んだら本気だす~">
1616

@@ -225,7 +225,7 @@ <h2 class="site-description">無職受験生 ~408に挑んだら本気だす
225225
<div class="not-found-card">
226226
<h1 class="article-title">Not Found</h1>
227227
<h2 class="article-subtitle">This page does not exist</h2>
228-
</div><form action="/npee_learning_log.github.io/page/search/" class="search-form widget" data-json="http://localhost:1313/npee_learning_log.github.io/page/search/index.json">
228+
</div><form action="/npee_learning_log.github.io/page/search/" class="search-form widget" data-json="https://auroraemiya.github.io/npee_learning_log.github.io/page/search/index.json">
229229
<p>
230230
<label>Search</label>
231231
<input id="searchInput" name="keyword" required placeholder="Type something..." />
@@ -281,7 +281,7 @@ <h3 class="search-result--title section-title"></h3>
281281
src="https://cdn.jsdelivr.net/npm/node-vibrant@3.1.6/dist/vibrant.min.js"integrity="sha256-awcR2jno4kI5X0zL8ex0vi2z&#43;KMkF24hUW8WePSA9HM="crossorigin="anonymous"
282282

283283
>
284-
</script><script type="text/javascript" src="/npee_learning_log.github.io/ts/main.d3ce7388ef5941233a2fd0541c1324f59fa8d8764f59d9721e2c172354121bcf.js" defer></script>
284+
</script><script type="text/javascript" src="/npee_learning_log.github.io/ts/main.1e9a3bafd846ced4c345d084b355fb8c7bae75701c338f8a1f8a82c780137826.js" defer></script>
285285
<script>
286286
(function () {
287287
const customFont = document.createElement('link');

public/categories/diary/index.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<!DOCTYPE html>
22
<html lang="zh-cn" dir="ltr">
3-
<head><script src="/npee_learning_log.github.io/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=npee_learning_log.github.io/livereload" data-no-instant defer></script><meta charset='utf-8'>
3+
<head><meta charset='utf-8'>
44
<meta name='viewport' content='width=device-width, initial-scale=1'><meta name='description' content="無職受験生 ~408に挑んだら本気だす~">
55
<title>Category: Diary - shyの考研日志</title>
66

7-
<link rel='canonical' href='http://localhost:1313/npee_learning_log.github.io/categories/diary/'>
7+
<link rel='canonical' href='https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/'>
88

99
<link rel="stylesheet" href="/npee_learning_log.github.io/scss/style.min.cfa5b1b0e78d61c00a14173992a1f3fa3b5c1b9fa34d023de959af564e7b19dd.css"><meta property='og:title' content="Category: Diary - shyの考研日志">
1010
<meta property='og:description' content="無職受験生 ~408に挑んだら本気だす~">
11-
<meta property='og:url' content='http://localhost:1313/npee_learning_log.github.io/categories/diary/'>
11+
<meta property='og:url' content='https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/'>
1212
<meta property='og:site_name' content='shyの考研日志'>
13-
<meta property='og:type' content='website'><meta property='og:updated_time' content=' 2025-09-06T12:18:02&#43;08:00 '/>
13+
<meta property='og:type' content='website'><meta property='og:updated_time' content=' 2025-09-07T23:32:48&#43;08:00 '/>
1414
<meta name="twitter:title" content="Category: Diary - shyの考研日志">
15-
<meta name="twitter:description" content="無職受験生 ~408に挑んだら本気だす~"><link rel="alternate" type="application/rss&#43;xml" href="http://localhost:1313/npee_learning_log.github.io/categories/diary/index.xml">
15+
<meta name="twitter:description" content="無職受験生 ~408に挑んだら本気だす~"><link rel="alternate" type="application/rss&#43;xml" href="https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/index.xml">
1616

1717
</head>
1818
<body class="
@@ -280,7 +280,7 @@ <h2 class="widget-title section-title">Archives</h2>
280280
<a href="/npee_learning_log.github.io/page/archives/#2025-09">
281281

282282
<span class="year">2025-09</span>
283-
<span class="count">5</span>
283+
<span class="count">6</span>
284284

285285
</a>
286286
</div>
@@ -333,12 +333,12 @@ <h2 class="widget-title section-title">Tags</h2>
333333
数据结构
334334
</a>
335335

336-
<a href="/npee_learning_log.github.io/tags/%E8%8B%B1%E8%AF%AD/" class="font_size_7">
337-
英语
336+
<a href="/npee_learning_log.github.io/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86/" class="font_size_8">
337+
计算机组成原理
338338
</a>
339339

340-
<a href="/npee_learning_log.github.io/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86/" class="font_size_7">
341-
计算机组成原理
340+
<a href="/npee_learning_log.github.io/tags/%E8%8B%B1%E8%AF%AD/" class="font_size_7">
341+
英语
342342
</a>
343343

344344
<a href="/npee_learning_log.github.io/tags/%E5%90%8C%E6%AD%A5/" class="font_size_3">
@@ -452,7 +452,7 @@ <h2 class="article-title">Intro-全部の始まり</h2>
452452
src="https://cdn.jsdelivr.net/npm/node-vibrant@3.1.6/dist/vibrant.min.js"integrity="sha256-awcR2jno4kI5X0zL8ex0vi2z&#43;KMkF24hUW8WePSA9HM="crossorigin="anonymous"
453453

454454
>
455-
</script><script type="text/javascript" src="/npee_learning_log.github.io/ts/main.d3ce7388ef5941233a2fd0541c1324f59fa8d8764f59d9721e2c172354121bcf.js" defer></script>
455+
</script><script type="text/javascript" src="/npee_learning_log.github.io/ts/main.1e9a3bafd846ced4c345d084b355fb8c7bae75701c338f8a1f8a82c780137826.js" defer></script>
456456
<script>
457457
(function () {
458458
const customFont = document.createElement('link');

public/categories/diary/index.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
33
<channel>
44
<title>Diary on shyの考研日志</title>
5-
<link>http://localhost:1313/npee_learning_log.github.io/categories/diary/</link>
5+
<link>https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/</link>
66
<description>Recent content in Diary on shyの考研日志</description>
77
<generator>Hugo -- gohugo.io</generator>
88
<language>zh-cn</language>
9-
<lastBuildDate>Sat, 06 Sep 2025 12:18:02 +0800</lastBuildDate><atom:link href="http://localhost:1313/npee_learning_log.github.io/categories/diary/index.xml" rel="self" type="application/rss+xml" /><item>
9+
<lastBuildDate>Sat, 06 Sep 2025 12:18:02 +0800</lastBuildDate><atom:link href="https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/index.xml" rel="self" type="application/rss+xml" /><item>
1010
<title>晴子の誕生日</title>
11-
<link>http://localhost:1313/npee_learning_log.github.io/diary/0905/</link>
11+
<link>https://auroraemiya.github.io/npee_learning_log.github.io/diary/0905/</link>
1212
<pubDate>Sat, 06 Sep 2025 12:18:02 +0800</pubDate>
1313

14-
<guid>http://localhost:1313/npee_learning_log.github.io/diary/0905/</guid>
14+
<guid>https://auroraemiya.github.io/npee_learning_log.github.io/diary/0905/</guid>
1515
<description>&lt;h1 id=&#34;彼女の誕生日&#34;&gt;彼女の誕生日
1616
&lt;/h1&gt;&lt;h2 id=&#34;手作り晩ご飯&#34;&gt;手作り晩ご飯
1717
&lt;/h2&gt;&lt;p&gt;今日はまだ平日だから、彼女が働いている間に僕は晩ご飯の食材を買いに行ってきた。
@@ -32,11 +32,11 @@
3232
</item>
3333
<item>
3434
<title>暴雨西湖</title>
35-
<link>http://localhost:1313/npee_learning_log.github.io/diary/westlake-with-haruko/</link>
35+
<link>https://auroraemiya.github.io/npee_learning_log.github.io/diary/westlake-with-haruko/</link>
3636
<pubDate>Sat, 12 Jul 2025 22:27:55 +0800</pubDate>
3737

38-
<guid>http://localhost:1313/npee_learning_log.github.io/diary/westlake-with-haruko/</guid>
39-
<description>&lt;img src="http://localhost:1313/npee_learning_log.github.io/diary/westlake-with-haruko/westlake_in_strom.jpg" alt="Featured image of post 暴雨西湖" /&gt;&lt;p&gt;今天带刚来杭州的&lt;strong&gt;太阳&lt;/strong&gt;(应当事人的要求使用该昵称)去西湖游玩。其实天气预报有雨,但东坡先生有诗为证:&lt;/p&gt;
38+
<guid>https://auroraemiya.github.io/npee_learning_log.github.io/diary/westlake-with-haruko/</guid>
39+
<description>&lt;img src="https://auroraemiya.github.io/npee_learning_log.github.io/diary/westlake-with-haruko/westlake_in_strom.jpg" alt="Featured image of post 暴雨西湖" /&gt;&lt;p&gt;今天带刚来杭州的&lt;strong&gt;太阳&lt;/strong&gt;(应当事人的要求使用该昵称)去西湖游玩。其实天气预报有雨,但东坡先生有诗为证:&lt;/p&gt;
4040
&lt;blockquote&gt;
4141
&lt;p&gt;水光潋滟晴方好,山色空蒙雨亦奇。
4242
欲把西湖比西子,淡妆浓抹总相宜。&lt;/p&gt;&lt;/blockquote&gt;
@@ -55,10 +55,10 @@
5555
</item>
5656
<item>
5757
<title>Intro-全部の始まり</title>
58-
<link>http://localhost:1313/npee_learning_log.github.io/diary/intro/</link>
58+
<link>https://auroraemiya.github.io/npee_learning_log.github.io/diary/intro/</link>
5959
<pubDate>Fri, 11 Jul 2025 16:35:21 +0800</pubDate>
6060

61-
<guid>http://localhost:1313/npee_learning_log.github.io/diary/intro/</guid>
61+
<guid>https://auroraemiya.github.io/npee_learning_log.github.io/diary/intro/</guid>
6262
<description>&lt;h2 id=&#34;写在一切的前面&#34;&gt;写在一切的前面
6363
&lt;/h2&gt;&lt;p&gt;欢迎来到我的博客,这是我 (笔者自称小shy)为了记录参加2026考研全过程而开始的新栏目。&lt;/p&gt;
6464
&lt;p&gt;我准备参加今年年底的2026NPEE(The national entrance examination for postgraduate),科目是11408。&lt;/p&gt;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="zh-cn">
33
<head>
4-
<title>http://localhost:1313/npee_learning_log.github.io/categories/diary/</title>
5-
<link rel="canonical" href="http://localhost:1313/npee_learning_log.github.io/categories/diary/">
4+
<title>https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/</title>
5+
<link rel="canonical" href="https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/">
66
<meta name="robots" content="noindex">
77
<meta charset="utf-8">
8-
<meta http-equiv="refresh" content="0; url=http://localhost:1313/npee_learning_log.github.io/categories/diary/">
8+
<meta http-equiv="refresh" content="0; url=https://auroraemiya.github.io/npee_learning_log.github.io/categories/diary/">
99
</head>
1010
</html>

0 commit comments

Comments
 (0)