English 中文(简体)
Dissasembling simple ARM instructions?
原标题:

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.

最佳回答

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.

问题回答

暂无回答




相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签