如何区分指令与数据? [英] How instructions are differentiated from data?

查看:36
本文介绍了如何区分指令与数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读ARM核心文档时,我有这个疑问.CPU如何区分读取数据和数据总线,是作为指令执行还是作为可以操作的数据执行?

While reading ARM core document, I got this doubt. How does the CPU differentiate the read data from data bus, whether to execute it as an instruction or as a data that it can operate upon?

参考文档摘录——

"数据进入处理器内核通过数据总线.数据可能是执行指令或数据项目."

"Data enters the processor core through the Data bus. The data may be an instruction to execute or a data item."

提前感谢您启发我!/MS

Thanks in advance for enlightening me! /MS

推荐答案

每个操作码将包含一个 N 字节的指令,然后期望后续的 M 字节为数据(内存指针等).因此 CPU 使用每个操作码来确定以下字节中有多少是数据.

Each opcode will consist of an instruction of N bytes, which then expects the subsequent M bytes to be data (memory pointers etc.). So the CPU uses each opcode to determine how manyof the following bytes are data.

当然对于旧处理器(例如旧的 8 位类型,如 6502 等)没有区别.您通常会将程序计数器指向内存中程序的开头,这将引用内存中其他位置的数据,但程序/数据存储为简单的 8 位值.处理器本身无法区分两者.

Certainly for old processors (e.g. old 8-bit types such as 6502 and the like) there was no differentiation. You would normally point the program counter to the beginning of the program in memory and that would reference data from somewhere else in memory, but program/data were stored as simple 8-bit values. The processor itself couldn't differentiate between the two.

完全可以将程序计数器指向被视为数据的内容,事实上,我记得我的教授在一个旧的大学教程中正是这样做的,我们必须指出错误给他.他的回答是但那是数据!它不能执行那个!可以吗?",此时我用有效的操作码填充了我们的数据,以证明它确实可以.

It was perfectly possible to point the program counter at what had deemed as data, and in fact I remember an old college tutorial where my professor did exactly that, and we had to point the mistake out to him. His response was "but that's data! It can't execute that! Can it?", at which point I populated our data with valid opcodes to prove that, indeed, it could.

这篇关于如何区分指令与数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆