0

Given a binary pattern in some memory location, is it possible to tell whether this pattern represents a machine instruction or a number? about computer architecture

  • Pretty sure No, but I suppose it depends on the architecture - there may be architectures that tag something as a data type or an instruction but I don't know of any. An early assembly class I had looked at the "meaning" of a binary pattern. And it could be an integer (maybe signed, maybe unsigned), could be fixed point, could be floating point, could be a string (in one of possibly many encodings: ascii, or ebcdic or unicode among). Could be part of an image (think bitmap for easiest example). Could be a CPU instruction (https://en.wikipedia.org/wiki/Self-modifying_code#Assembly_language). – jgreve Mar 08 '20 at 16:41
  • The whole point of a Von Neumann stored-program machine is that programs *are* data. If a byte gets fetched as part of an instruction (i.e. execution reaches it), it gets treated as an instruction. If it's accessed by a data load/store instruction, then it's data. These things are not necessarily exclusive, although usually executable pages are made read-only and writeable pages non-executable. It's up to the programmer not to execute data as code or vice versa when that's not what you want. – Peter Cordes Mar 08 '20 at 16:45

0 Answers0