《Computer Organization and Design》Chap.2 笔记1

2.1-2.10提要:

  1. 高级语言中的数学运算、逻辑运算、跳转、递归函数等如何转化为RISC-V中的汇编语言?
  2. RISC-V汇编语言如何转化为机器语言?
  3. 内存读写
  4. 二进制补码表示法
  5. 寄存器x0-x31的作用

内容:

The size of a register in the RISC-V architecture is 64 bits; groups of 64 bits occur so frequently that they are given the name doubleword in the RISC-V architecture.

一个word等于几个bytes ( or bits) ?需要注意的是,在不同的计算机体系中是不一样的,详见wiki Word 条目, RISC-V、ARM和MIPS中 1word = 32 bit = 4 byte。

A very large number of registers may increase the clock cycle time simply because it takes electronic signals longer when they must travel farther.

寄存器的数目越多,可能导致clock cycle time增加。为何寄存器个数通常为32个?可参考stackexchange.com: Why does a processor have 32 registers?

数学运算:add, sub, addi
加载和存储:ld, sd,尤其需要注意内存地址。
Memory Addresses
unsigned and signed numbers.
字节装载:lbu, lb

Two useful shortcut:

  1. A quick way to negate a two’s complement binary number : Simply invert every 0 to 1 and every 1 to 0, then add one to the result.
  2. Sign extension: take the sign bit and replicate it to fill the new bits of the larger quantity.

逻辑运算:slli, srli, srai, sll, srl, sra, and, or, xor, andi, ori, xori
比较: beq, bne, blt, bge, bltu, bgeu。在ARM中则用condition codes or flags来实现。
跳转:jal, jalr,注意leaf procedures和Nested Procedures的实现!

寄存器x0-x31:
Register conventions

4种寻址方式:
Addressing modes

5种机器语言格式:
Instruction formats

猜你喜欢

转载自blog.csdn.net/u013213111/article/details/85255329
今日推荐