反汇编简单的 ARM 指令?

发布于 2024-09-14 06:16:25 字数 753 浏览 9 评论 0原文

我一直在摆弄 IDA Pro,并试图为了它而拆解我自己的产品。

我注意到一些我不明白的事情,因为我的汇编语言知识很糟糕。下面是一小段调用CGContextSetRGBStrokeColor的代码。

CGContextSetRGBStrokeColor(ctx, 1, 1, 1, 1);

在 IDA 中,它看起来像这样:

IDA Output

我不明白很多事情:

  1. 0x3F800000< 是如何做到的/strong> 与数字 1 有关吗?我认为这是一个参考,但我不明白它指的是什么。
  2. 为什么 MOVS 被调用三次而不是四次(因为有四个参数)?
  3. R0、R1、R2等是CPU寄存器吗?
  4. 有人可以解释一下这些:

一些文本行http://a.imageshack.us/img836/ 4018/gah.png

此文件是一个框架(因此是一个Mach-O 文件)。该函数来自 CoreGraphics。

I've been messing around with IDA Pro and trying to disassemble my own products just for the sake of it.

I've noticed a couple of things I don't understand because my assembly language knowledge is terrible. Here is a little chunk of code which invokes CGContextSetRGBStrokeColor.

CGContextSetRGBStrokeColor(ctx, 1, 1, 1, 1);

In IDA it looks like this:

IDA Output

I don't understand a number of things:

  1. How does 0x3F800000 relate to the number 1? I assume it is a reference, however I did not get what it refers to.
  2. Why is MOVS being called three times instead of four (because there are four arguments)?
  3. Are R0,R1,R2 etc. CPU registers?
  4. Could someone explaing these:

Some text lines http://a.imageshack.us/img836/4018/gah.png

This file is a Framework (therefore a Mach-O file). That function comes from CoreGraphics.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔女人霸气范 2024-09-21 06:16:25

0x3F800000 与数字 1 有何关系?我认为它是一个参考,但我没有得到它所指的内容。

0x3F800000 在 IEEE 单精度表示中是 1.0。您可以右键单击该 0x3F800000 并选择浮点表示形式将其转换为 1.0。

为什么 MOVS 被调用三次而不是四次(因为有四个参数)?

在标准 ARM 调用约定中,前 4 个参数分别存储在 R0 到 R3 中。 ldr r1, =0x3f800000 指令已存储第二个参数。

R0、R1、R2等是CPU寄存器吗?

是的。

有人可以解释一下这些吗:

请不要拆开非连续指令,因为第二条指令的 r3 和第三条指令的 r3 不同。

如果检查整个函数,您应该会看到“var_4C”是堆栈上变量 ctx 的地址。因此,

add r3, sp, #0x50+var_4c
ldr r2, [r3]

仅表示r2 = ctx。指令movs r0, r2稍后将上下文作为第一个参数。

另外,在 ARM 中,var_??相当于值-0x??。在 ARM 中,第 5 个及以上参数存储在堆栈中的 [sp, #0]、[sp, #4] 等位置。因此,指令

ldr r3, =0x3f800000
str r3, [sp, #0]     ;// #0x50+var_50 = 0x50 - 0x50 = 0

将 1.0 放在第 5 个参数处。

How does 0x3F800000 relate to the number 1? I assume it is a reference, however I did not get what it refers to.

0x3F800000 is 1.0 in IEEE single precision representation. You could right click on that 0x3F800000 and choose floating point representation to convert it to 1.0.

Why is MOVS being called three times instead of four (because there are four arguments)?

In the standard ARM calling convention, the first 4 arguments are stored in R0 to R3 respectively. The ldr r1, =0x3f800000 instruction already stores the 2nd argument.

Are R0,R1,R2 etc. CPU registers?

Yes.

Could someone explaing these:

Please don't take apart non-consecutive instructions, since the r3 at the 2nd instruction and that in the 3rd are different.

If you check the whole function, you should see that "var_4C" is the address to the variable ctx on stack. Hence,

add r3, sp, #0x50+var_4c
ldr r2, [r3]

just means r2 = ctx. The instruction movs r0, r2 much later put the context as the 1st argument.

Also, in ARM, var_?? is equivalent to the value -0x??. In ARM, the 5th argument and above are stored on the stack at [sp, #0], [sp, #4], etc. Hence, the instruction

ldr r3, =0x3f800000
str r3, [sp, #0]     ;// #0x50+var_50 = 0x50 - 0x50 = 0

put the 1.0 on at the 5th argument.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文