跳转至

第 1 周

CPU 的执行

  • Fetch
  • Instruction decoding and Read Operand
  • Exec Control
  • Memory Access
  • Write results to register
  • Modify PC

单纯的多周期?

  • 指令时间仍然更长了
  • 但是……能否重新设计 CPU?
    • 流水线?

指令集的设计

ISA 的分类

内部存储有这些类型:

  • 累加器
  • 寄存器

寄存器方面(GPR 分类):

  • Memory-memory architecture,存储器就是寄存器……好慢,现在已经不使用了。
  • Register-memory architecture,啥指令都能访问存储器。
  • Register-register architecture,必须要 load 和 store 才能访问存储器。

D = A * B - (A + C * B)

栈:

push a
push b
mul
push a
push c
push b
mul
add
sub
pop d

累加器:

1
2
3
4
5
6
7
8
load c
mul b
add a
store d
load a
mul b
sub d
store d

R-M:

1
2
3
4
5
6
7
8
load r1, b
mul r1, c
add r1, a
store d, r1
load r1, a
mul r1, b
sub r1, d
store d, r1

内存与地址

长度

  • 1 byte = 8 bits
  • 1 half word = 16 bits
  • 1 word = 32 bits
  • 1 double word = 64 bits

存储顺序

大端序:高位的数据会存在低的地址。

小端序:低位的数据会存在低的地址。

地址对齐

寻址模式