简体   繁体   English

16位Thumb-2汇编指令集中的“更新条件标志” S如何编码?

[英]How is the “update condition flags” S encoded in the 16-bit Thumb-2 assembly instruction set?

So I need to write a very basic disassembler for class and I'm having a hard time figuring out how the S that can be appended to Thumb instructions is encoded. 因此,我需要为类编写一个非常基本的反汇编程序,而且我很难确定可以附加到Thumb指令的S是如何编码的。

For example, the instruction 0x0011 corresponds with the following assembly code: 例如,指令0x0011与以下汇编代码相对应:

movs    r1, r2

Why wouldn't it just be a regular mov? 为什么这不是常规动作?

Likewise, 0x1889 corresponds with: 同样,0x1889对应于:

adds    r1, r1, r2

As far as I can tell from reading the reference manual, this is the same encoding as the regular add instruction without the S. Is this the case? 据阅读参考手册所知,这与不带S的常规加法指令的编码相同。是这种情况吗? How is the instruction for updating condition flags sent? 如何发送条件标记更新指令?

gnu assembler is very annoying and messes up instruction sets, but that is another story. gnu汇编器很烦人,弄乱了指令集,但这是另一回事了。 for thumb mode dont put the s it complains but since you do not have a choice it is always there. 对于拇指模式,请不要抱怨它,但是由于您没有选择的余地,所以它总是存在的。 just do an add r1,r2 assemble then disassemble and you will see the adds r1,r2 also if you double check and look at the machine instruction relative to what the manual says it also shows that the update flags will happen 只需做一个加法r1,r2的组装,然后反汇编,如果您仔细检查并查看与手册说的相对的机器指令,它也会显示更新标志,您还将看到加法r1,r2。

0x0011 is a lsl immed_5, rm, rn so that is lsl r1,r2,#0 not an add. 0x0011是lsl immed_5,rm,rn,因此是lsl r1,r2,#0(不是加号)。

0x1889 is indeed an add r1,r1,r2. 0x1889确实是加法r1,r1,r2。 the s is not a bit in the instruction set for thumb it is implied. s并不暗示它在拇指指令集中。

Thumb doesn't use the S condition field for each instruction, so every instruction is unconditional (aside from the conditional branches, obviously). Thumb不会为每条指令使用S条件字段,因此每条指令都是无条件的(显然,除了条件分支之外)。 Part of the reduction from 32-bit ARM to 16-bit Thumb involved getting rid of it. 从32位ARM减少到16位Thumb的一部分涉及到摆脱它。 The examples you provided shouldn't have the s to begin with, in my opinion (they don't get used in this manual ). 您提供的例子不应该有s ,首先,在我看来(他们没有得到在使用本手册 )。

Condition codes in Thumb are set implicitly by your ALU instructions (same as ARM), but to access them you need to use conditional branches. Thumb中的条件代码由ALU指令(与ARM相同)隐式设置,但是要访问它们,您需要使用条件分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM