美文网首页
Instructions: Language of the

Instructions: Language of the

作者: 刘东利2020 | 来源:发表于2022-12-30 13:40 被阅读0次

2.5 Representing Instructions in the Computer

顾名思义,这一节是讲如何将RISC-V指令在电脑中实现。

先看2个概念:

instruction format A form of representation of an instruction composed of fields of binary numbers.

machine language Binary representation used for communication within a computer system.

这是一层一层的翻译了 —— 指令集有其格式,而表示指令集格式的语言是机器语言,告诉机器如何操作的语言。

第一个例子,讲一下基本逻辑:

针对以上的例子,有如下的定义:

opcode: Basic operation of the instruction, and this abbreviation is its traditional name.

rd: The register destination operand. It gets the result of the operation.

funct3: An additional opcode field.

rs1: The first register source operand.

rs2: The second register source operand.

funct7: An additional opcode field.

除了R型(R-type (for register)),进一步扩展,还有其他两种类型(I和S)至今用到的:

可以看到,指令长度是相同的:

The compromise chosen by the RISC-V designers is to keep all instructions the same length, thereby requiring distinct instruction formats for different kinds of instructions.

这背后是第三个原则:

Design Principle 3: Good design demands good compromises.

第二个示例:

参照指令格式的表格,答案是:

其他几个示例:

以上这种将指令也作为数字的处理方式,背后是一个重要的概念:

Today’s computers are built on two key principles:

1. Instructions are represented as numbers.

2. Programs are stored in memory to be read or written, just like data.

These principles lead to the stored-program concept; its invention let the computing genie out of its bottle.

一切都是数字:

这带来了技术和商业上的集中化 —— 根源于其背后的是,数字与代码的零复制成本:

One consequence of instructions as numbers is that programs are often shipped as files of binary numbers. The commercial implication is that computers can inherit ready-made software provided they are compatible with an existing instruction set. Such “binary compatibility” often leads industry to align around a small number of instruction set architectures.

相关文章

网友评论

      本文标题:Instructions: Language of the

      本文链接:https://www.haomeiwen.com/subject/ilbxcdtx.html