After the assembly language is created it is necessary to determine how to represent each instruction as a number. |
汇编语言建立后,有必要确定如何来用数字声明每一个指令。 |
This establishes a one-to-one correspondence between each instruction in the assembly language and each instruction code in the set of instruction codes. |
在汇编语言中,每个指令和每个指令集的都建立了一一对应的关系。 |
Converting a program from assembly language to instruction codes is called assembling, and conversion from instruction codes back into assembly language is called disassembling. |
将程序从汇编语言转换为指令叫做汇编,把指令转换为汇编语言叫做反汇编。 |
Several choices we must make at this point are: |
这一点我们必须做出的选择是: |
What number is used to represent each assembly language instruction? |
什么数字来代表汇编语言的每个指令? |
How are instruction operands encoded? |
指令如何运算编译? |
Are operands part of the instruction word (remember, by word I mean number), or are they separate words (numbers)? |
运算部分的指令词(记住,我的意思是数字),还是分开的指令词(数字们)? |
First, to answer the last question, since there are only small numbers of instructions and registers in this VM it should not be very difficult to encode all operands in a single instruction word, even if (for the sake of simplicity) I were to use a 16-bit instruction word. |
首先,回答最后的问题,自从仅有小数字指令的时候以及虚拟机内含的单指令完全可以不费力的完成所有运算,甚至(简单来说)我之前一直用的16位指令。 |
Thus, a 16-bit number written in hexadecimal has 4 digits, giving us easy access to 4 information fields, each containing 16 variations (0-9 and A-F). |
因此,一个16位代码写为16进制4位数字,让我们容易获取4个数字的信息,每一位包含16种变量可能(0-9 和 A-F) |
The first digit of a machine word will be the instruction number. |
机器的第一位数字是指令。 |
This gives our VM the potential for having up to 16 different instructions. |
这给了我们的虚拟机可能性来上升到16个不同的指令集。 |
This is a small amount by contemporary standards, but it is plenty for our example virtual machine. |
这样小数量的是当代社会的标准,但是对于我们样品虚拟机来说意味着很多。 |
The next three digits will be used for the operands. |
下面的三个数字将用在运算中。 |
These can be used as three 1-digit operands, two operands of 1 and 2 digits, or a single 3-digit operand. |
这些可以是三次1位运算,两次1和2位,或者一次三位运算。 |
Having made these decisions, let us now establish the encoding. |
做出这些决定,让我们现在开始建立编译。 |
Recall that we have 16 instruction numbers available. |
我们有16个指令数字可以回叫 |
The halt instruction will be instruction 0, and there is an important reason for choosing 0 for this instruction. |
用指令0挂起指令,选择0作为这个指令有重要的意图。 |
Since empty space in the computer's memory will most likely be filled with 0s, any run-away program will eventually encounter a 0 and attempt to execute this instruction, immediately halting the program. |
当电脑内存有空闲时,会填充0s,任何执行的程序最终遇到0并试图执行这个指令,将立刻挂起程序。 |