开发者

CGPatternGetStep() signature?

Can anybody please explain me the following assembly?

_CGPatternGetStep:
    +0  0007fb86  55                      pushl       %ebp
    +1  0007fb87  89e5                    movl        %esp,%ebp
    +3  0007fb89  53                      pushl       %ebx
    +4  0007fb8a  8b4508                  movl        0x08(%ebp),%eax
    +7  0007fb8d  8b504c                  movl        0x4c(%eax),%edx
   +10  0007fb90  8b5850                  movl        0x50(%eax),%ebx
   +13  0007fb93  89d0                    movl        %edx,%eax
   +15  0007fb95  89da                    movl        %ebx,%edx
   +17  0007fb97  5b                      popl        %ebx
   +18  0007fb98  c9                      leave
   +19  0007fb99  c3                      ret

I want to find out the step passed in method CGPatternCreate ( void *info, CGRect bounds, CGAffineTransform matrix, CGFloat xStep, CGFloat yStep, CGPatternTiling tiling, bool isColored, const CGPatternCallbacks *callbacks 开发者_开发技巧);

I want to find xStep and yStep Values? I have CGPatternRef with me. Can above disassembly of function be used for getting xStep and yStep?


pushl       %ebp
movl        %esp,%ebp
pushl       %ebx

Setup stack frame and save register ebx.

movl        0x08(%ebp),%eax

Load the first stack argument (from ebp+8) into eax.

movl        0x4c(%eax),%edx

Load a 32-bit value from the field at offset 0x4C from the address in eax into edx.

movl        0x50(%eax),%ebx

Load a 32-bit value from the field at offset 0x50 from the address in eax into ebx.

movl        %edx,%eax
movl        %ebx,%edx

Move the previously loaded values into eax and edx, respectively.

popl        %ebx
leave
ret

Restore saved register ebx, tear down stack frame and return.

Since the code sets both eax and edx just before returning, we can conclude that the return type is 64-bit. You can also note that the two loads are for consecutive locations (0x4C+4==0x50). So, most likely the first (and sole) argument is a pointer to a structure that has a 64-bit member at offset 0x4C, and the function returns its value.

typedef struct _CGPattern
{
 ...
 uint64_t step; // offset 0x4C
 ...
} CGPattern;

uint64_t CGPatternGetStep(CGPattern *pat)
{
  return pat->step;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜