本文主要是介绍《Computer Organization and Design》Chap.2 笔记1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
2.1-2.10提要:
- 高级语言中的数学运算、逻辑运算、跳转、递归函数等如何转化为RISC-V中的汇编语言?
- RISC-V汇编语言如何转化为机器语言?
- 内存读写
- 二进制补码表示法
- 寄存器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,尤其需要注意内存地址。
unsigned and signed numbers.
字节装载:lbu, lb。
Two useful shortcut:
- 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.
- 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:
4种寻址方式:
5种机器语言格式:
这篇关于《Computer Organization and Design》Chap.2 笔记1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!