如何确定是否一个字(4字节)是一个16位指令或32位的指令? [英] How to determine if a word(4 bytes) is a 16-bit instruction or 32-bit instruction?

查看:351
本文介绍了如何确定是否一个字(4字节)是一个16位指令或32位的指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道,如果在字中的字节重新present 16位指令或32位指令?结果
我提到了ARM ARMv7M,我并不清楚如何区分,如果它的16位指令或32位指令。结果
它说结果
如果半字之中去codeD的位[15时11分]采取下列值,半字是一个32位指令的第一个半字:结果
•0b11101
•0b11110
•0b11111。
否则,半字是一个16位指令

How do I know if the bytes in the word represent a 16-bit instruction or a 32-bit instruction ?
I referred the ARM ARMv7M and I am not clear how to distinguish if it a 16-bit instruction or a 32-bit instruction.
It says
If bits [15:11] of the halfword being decoded take any of the following values, the halfword is the first halfword of a 32-bit instruction:
• 0b11101 • 0b11110 • 0b11111. Otherwise, the halfword is a 16-bit instruction

这是否意味着处理器总是取半字,对它们进行检查并确定它是否是16位或32位?结果
什么是第一个半字是什么意思?位[31-16]或位[15-0]一句话?

Does it mean that the processor always fetches halfwords, examines them and decides if it's 16 or 32-bit ?
What does the first halfword mean ? Bit[31-16] or Bit[15-0] in a word ?

如果我有32位,然后我可以知道这是否是一个32位指令或16位指令?

If I have 32-bits then can I know if it's a 32-bit instruction or a 16-bit instruction ?

感谢。

推荐答案

在拇指,32位的指示仍然由两个独立的半字,所以先半字是第一个半字的的编码的,它没有提到在内存中的布局。拇指指令半字对齐的,所以存储器中的任何给定的字可以容纳2个16位的指令,一个16位指令和32位指令的一半,两个不同的32位指令两半,或一整32比特指令。

In Thumb, "32-bit" instructions are still composed of two separate halfwords, so the "first halfword" is the first halfword of the encoding, which says nothing about the layout in memory. Thumb instructions are halfword-aligned, so any given word of memory could hold two 16-bit instructions, a 16-bit instruction and one half of a 32-bit instruction, two halves of two different 32-bit instructions, or one whole 32-bit instruction.

从概念上讲,处理器德codeS 1半字的时间,因此如果它看到上面的位模式之一,它知道它需要也去code中的下一个半字,才可以实际执行该指令。现实的复杂性这个有点以来的Cortex-M3 / M4 <一个href=\"http://infocenter.arm.com/help/topic/com.arm.doc.100165_0201_00_en/Chunk475997833.html#ric1414069345626\"相对=nofollow>只会实际上从内存中取整 32位的话,那么数量之间的关系取指令,并执行的指令实际上去codeD的数量和依赖于code本身。试想一下,这些都取笔芯的管道吸食了个别半字一个4字节的缓冲区(这可能不是所有的遥远真相,为我所知道的)。

Conceptually, the processor decodes one halfword at a time, thus if it sees one of the above bit patterns, it knows it needs to also decode the next halfword before it can actually execute this instruction. Reality complicates this somewhat since the Cortex-M3/M4 only ever actually fetch whole 32-bit words from memory, so the correlation between the number of "instruction fetches" and the number of instructions actually decoded and executed depends on the code itself. Just imagine that those fetches are to refill a 4-byte buffer that the pipeline slurps individual halfwords out of (which may not be all that far off the truth, for all I know).

所以,如果你有一个包含在它的顶部位的值的一个半字,那么你就知道这是一个32位编码的前半部分,你需要跨preT它连同下一个半字。相反,如果你有一个半字,在其顶部位的任何其他值,那么它是一个16位编码,或一个32位编码的下半年,这取决于previous半字是什么。

So, if you have a halfword containing one of those values in its top bits, then you know it's the first half of a 32-bit encoding, and you need to interpret it in conjunction with the next halfword. Conversely, if you have a halfword with any other value in its top bits, then it's either a 16-bit encoding, or the second half of a 32-bit encoding, depending on what the previous halfword was.

请注意该指令是总是小端,所以在32位编码的实际内存布局看起来像这样,在地址A是偶数

Note that instructions are always little-endian, so the actual in-memory layout of a 32-bit encoding looks like this, where address A is an even number:

          --------------------------------
address A | bits 7:0 of first halfword   |
          --------------------------------
      A+1 | bits 15:8 of first halfword  |
          --------------------------------
      A+2 | bits 7:0 of second halfword  |
          --------------------------------
      A+3 | bits 15:8 of second halfword |
          --------------------------------

这篇关于如何确定是否一个字(4字节)是一个16位指令或32位的指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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