汇编器修补比较指令和分支
我怎样才能使这个说明“真实”?
CMP R0, #0
我想做的是,例如 make
CMP R0,R0 or CMP #0, #0
00 28 是操作码。我尝试执行 28 28
但没有结果! 另一个问题 BNE.W
是什么指令?最后的W是什么? 我如何在 BE 中修改它?操作码为 40 F0 65 85
注意:所有操作码均处于拇指模式!
* 编辑 Mac 上有armv7 编译器吗?
How Can I make "true" this istrution?
CMP R0, #0
What I want to do is for example make
CMP R0,R0 or CMP #0, #0
00 28 is the op code. I try to do 28 28
without results!
Another question
what kind of istructions is BNE.W
? what this the final W?
How can I mod that in a BE? op code is 40 F0 65 85
NOTE: All op codes are in thumb mode!
* EDIT
Does exists an armv7 compiler for Mac?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以简单地汇编
CMP R0, R0
或CMP #0, #0
并以这种方式从这些指令中提取所需的操作码。另一种方法是查看 ARM 参考手册并手动构建操作码。 这是一本 ARMv5 手册,我很快找到并在下面
7.1.22
您有CMP,
以及构建用于比较两个寄存器的操作码的详细信息。细节似乎与我在发布之前发现的 ARMv7 手册相同。它的第 15-6 位是
0 1 0 0 0 0 1 0 1 0
,然后第 5-3 位是第一个寄存器的编号(对于R0<,数字 0 由 3 位表示/code>),位 2-0 是第二个寄存器(也是
R0
)。所以你的操作码现在是:0 1 0 0 0 0 1 0 1 0
(CMP
)000
(R0
)000
(R0
)100001010000000
十六进制为4280
,因此按照小端顺序,您需要的两个字节是80 42
。正如您所看到的,让汇编器为您解决这个问题会快得多。
You can simply assemble
CMP R0, R0
orCMP #0, #0
and extract the needed opcode from those instructions that way.Another way is to look at an ARM reference manual and manually build up the opcode. This is an ARMv5 manual I quickly found and under
7.1.22
you haveCMP <Rn>, <Rm>
with details of building the opcode for comparing two registers. The details seem to be the same as an ARMv7 manual I also found just before I was about to post.It has bits 15-6 being
0 1 0 0 0 0 1 0 1 0
, then bits 5-3 are the number of the first register (number 0 represented by 3 bits forR0
), and bits 2-0 being the second register (alsoR0
). So your opcode would now be:0 1 0 0 0 0 1 0 1 0
(CMP
)000
(R0
)000
(R0
)100001010000000
in hex is4280
, therefore in little-endian order the two bytes you need are80 42
.As you can see, it'd be a lot quicker to just let an assembler work that out for you.