原始图灵机上的操作的汇编语言等价物是什么?
如果采用原始图灵机定义如下:
...无限的内存容量 以无穷大的形式获得 胶带已标记出来 分成正方形,每个正方形上都可以打印一个符号。随时 有 机器中的一个符号;它称为扫描符号。机器 可以改变 扫描的符号及其行为部分取决于 符号,但是 磁带上其他地方的符号不会影响磁带的行为 机器。然而, 磁带可以在机器中来回移动,这是 中的一个 机器的基本操作。磁带上的任何符号都可能 所以 最终有一局。 (图灵,1948 年,第 61 页)
如果您想将这些操作映射到能够解释汇编程序/二进制指令的处理器上完成的操作 - 将映射哪些操作?
(我知道这个问题固有的从图灵机到冯诺依曼机的跳跃)
If you take the original Turing machine definition as follows:
...an infinite memory capacity
obtained in the form of an infinite
tape marked out
into squares, on each of which a symbol could be printed. At any moment
there is
one symbol in the machine; it is called the scanned symbol. The machine
can alter
the scanned symbol and its behavior is in part determined by that
symbol, but the
symbols on the tape elsewhere do not affect the behavior of the
machine. However,
the tape can be moved back and forth through the machine, this being
one of the
elementary operations of the machine. Any symbol on the tape may
therefore
eventually have an innings. (Turing 1948, p. 61)
If you want to map these operations to those done on a processor capable of interpreting assembler/binary instructions - which operations would be mapped?
(I'm aware of the jump from Turing machines to Von Neuman machines inherent in this question)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
阅读您所写的内容,我想说您只需要:
响应当前 类似于 ARM 的汇编,例如,如果您有 R0 包含磁带上的地址,您应该只需要
然后,在当前符号假定某些值的情况下分支执行操作
这或多或少是 Brainfuck 的工作方式。
Reading what you've written I'd say you just need:
In an ARM-like assembly, for example, if you have R0 containing the address on the tape you should just need
Then, branches to do stuff in case of certain values assumed by the current symbol
This is more or less how Brainfuck works.
我们称之为 int 数组。
int[] 符号
(在 CPU 级别,这被称为“主存储器”或在现代系统中被称为“程序段”。
(在 CPU 级别,这是“执行指令”。没有操作代码告诉它这样做;这只是 CPU 所做的事情。)
那里没什么可做的。
(在CPU级别,这是用JMP操作码处理的)
Let's call that a int array.
int[] Symbols
(At the CPU level, this is known as "main memory" or in modern system "program segment".
(At the CPU level, this is "executing an instruction". There is no op code to tell it to do so; it's just what CPU do.)
Nothing to do there.
(At the CPU level, this is handle with JMP op codes)
由于图灵机完全由磁带上字母表的定义和正在读取磁带的状态机决定,因此将语言设置为表格是最有意义的。
我们将状态称为 Qn,字母表字符 Ai 从磁带。机器从转换表 an 确定下一个状态,并将 Ao 写入磁带并沿 D : L/R 方向移动。
来定义机器
然后可以通过写入其QnAi → 。 QmAoD
来自维基百科的添加程序将变为
接受状态和拒绝状态。这是非常紧凑且可读的转移矩阵表示。
当然,这是假设磁带上的内容被解释为数据。但是没有什么可以阻止任何人创建转换矩阵以使状态机解释磁带上的指令。
为了实现这一点,您在左侧有一个元组,在右侧有一个三元组,因此这映射到二维数组中的查找来读取三元组。用磁带上字符的#bits 改变状态并将它们粘在一起。相乘(好吧,另一个移位运算)为三元组腾出空间,并将其用作表中的偏移量来读取三元组。
将新状态写入状态寄存器,磁带上的字符,如果在三元组中找到数据,则增加递减,或者停止那里没有数据。组装起来应该很有趣。
Since the turing machine is completely determined by the definition of the alfabet on the tape and the state machine which is reading the tape it would make most sense to make the language like a table
Lets call the states Qn, the Alfabet characters Ai read from the tape. The machine determines the next state from the transisiton table an and writes Ao to the tape and moves in the direction D : L/R
The machine can then be defined by writing its
QnAi -> QmAoD
The adding program from wikipedia would then become
wit a the accepting state and r the rejecting state. This is pretty compact and a readable presentation of the transisition matrix.
This of course assumes that what is on the tape is interpreted as data. But nothing stops anyone of creating the transition matrix to make the statemachine interprete instruction from the tape.
To implement this you have on the left side a tuple and on the right side a triple, so this maps on a lookup in a 2D array to read the triplet. Shift the state with the #bits of the character on the tape and stick them together. Multiply (ok, another shift operation) to make room for the triplet, and use that as the offset in a table to read the triplet.
Write the new state in the state register, the char on the tape, and inc decrement, if you find data in the triplet, or stop of there is no data there. Should be fun in assembly.
我不确定这是否 100% 正确,但它会是这样的:
注意,磁头运动控制相当于流程控制指令,即JMP及其兄弟指令。
另请注意,寄存器是经典 TM 的重要补充。它们可以表示为磁带上的特殊单元(或单元组)或单独的实体。有关更多详细信息,请参阅注册机器。
最后,值得一提的是,虽然这非常适合冯·诺依曼架构,但哈佛架构使用两种不同的磁带,一种用于指令,一种用于数据。
I'm not sure if this is 100% correct, but it would go something like this:
Note that head movement control is equivalent to flow control instructions, i.e. JMP and its brothers.
Also note that the registers are an important addition to the classical TM. They could be represented as special cells (or sets of cells) on the tape or as separate entities. See the register machine for more details.
Finally, it's important to mention that while this works perfectly for the Von Neumann architecture, the Harvard architecture uses two distinct tapes, one for instructions and one for data.