Skip to content

Commit

Permalink
Update example.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ksitta authored Oct 21, 2024
1 parent 603eb1e commit fa66a7f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions docs/step9/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int func(int x, int y) { int x = 1; return x + y; }

## 中间代码生成

为了实现函数,我们需要设计至少一条中间代码指令来表示函数调用,给出的参考定义如下:
为了实现函数,我们需要设计至少一条中间代码指令来表示函数调用,给出的参考定义如下**推荐大家这样实现**

> 请注意,TAC 指令的名称只要在你的实现中是一致的即可,并不一定要和文档一致。
Expand All @@ -58,7 +58,7 @@ T0 = CALL foo(T1, T2)

> 在早先的文档中,函数调用涉及`CALL``PARAM`两种指令。`CALL`指令只对应实际汇编代码的函数调用,而`PARAM T0`指令用于传递一个参数。
> 假设我们有若干个参数,可以依次使用 PARAM 命令将它们加入参数列表。在调用函数时,这些参数的值会自动依次按顺序装载到临时变量 _T0, _T1 ... 中。比如我们有这样一段 TAC 程序:
> 假设我们有若干个参数,可以依次使用 PARAM 命令将它们加入参数列表。在调用函数时,这些参数的值会自动依次按顺序装载到临时变量 _T0, _T1 ... 中。比如我们有这样一段 TAC 程序**不推荐按照这样实现,可能会造成数据流分析困难**
```assembly
PARAM A
Expand All @@ -67,14 +67,6 @@ PARAM C
XX = CALL XXX
```

> 那么,在进入 XXX 函数时,相当于执行了:
```assembly
_T0 = A
_T1 = B
_T2 = C
```

> 因此,示例可以对应如下的 TAC 程序:
```assembly
Expand Down

0 comments on commit fa66a7f

Please sign in to comment.