[Galaxy S II Android Development] majdinj:
Just refreshment knowledge

Just refreshment knowledge​

.locals: is for v variables

.registers: is for v and p variables where p variables are stored in the last variables in the raw

Practical example:

.method public xdaExampleMethod(IILandroid/content/Intent;)V
[B][COLOR="Red"].registers 9[/COLOR][/B]
.param [B][COLOR="Green"]p0[/COLOR][/B], "Lcom/sec/android/app/newApp"
.param [B][COLOR="Green"]p1[/COLOR][/B], ""id" # I"
.param [B][COLOR="Green"]p2[/COLOR][/B], "title" # I
.param [B][COLOR="Green"]p3[/COLOR][/B], "activity"

.prologue
const/4 [B][COLOR="Green"]v0[/COLOR][/B], -0x1

const/4 [B][COLOR="Green"]v1[/COLOR][/B], 0x1

const/4 [B][COLOR="Green"]v2[/COLOR][/B], 0x0

iget-object [B][COLOR="Green"]v4[/COLOR][/B], [B][COLOR="Green"]p0[/COLOR][/B], Lcom/sec/android/app/newApp;->mContext:Landroid/content/Context;

invoke-virtual {[B][COLOR="Green"]v4[/COLOR][/B]}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object [B][COLOR="Green"]v4[/COLOR][/B]

const-string [B][COLOR="Green"]v3[/COLOR][/B], "contacts_list_photo"

invoke-static {[B][COLOR="Green"]v4[/COLOR][/B], [B][COLOR="Green"]v3[/COLOR][/B], [B][COLOR="Green"]v2[/COLOR][/B]}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result [B][COLOR="Green"]v4[/COLOR][/B]

Here .registers 9 means (v0, v1, v2, v3, v4, p0, p1, p2, p3).

v0

v1

v2

v3

v4

v5 = p0

v6 = p1

v7 = p2

v8 = p3

So you can safely write the method as following:

.method public xdaExampleMethod(IILandroid/content/Intent;)V
[B][COLOR="Red"].registers 9[/COLOR][/B]
.param [B][COLOR="Green"]v5[/COLOR][/B], "Lcom/sec/android/app/newApp"
.param [B][COLOR="Green"]v6[/COLOR][/B], ""id" # I"
.param [B][COLOR="Green"]v7[/COLOR][/B], "title" # I
.param [B][COLOR="Green"]v8[/COLOR][/B], "activity"

.prologue
const/4 [B][COLOR="Green"]v0[/COLOR][/B], -0x1

const/4 [B][COLOR="Green"]v1[/COLOR][/B], 0x1

const/4 [B][COLOR="Green"]v2[/COLOR][/B], 0x0

iget-object [B][COLOR="Green"]v4[/COLOR][/B], [B][COLOR="Green"]v5[/COLOR][/B], Lcom/sec/android/app/newApp;->mContext:Landroid/content/Context;

invoke-virtual {[B][COLOR="Green"]v4[/COLOR][/B]}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object [B][COLOR="Green"]v4[/COLOR][/B]

const-string [B][COLOR="Green"]v3[/COLOR][/B], "contacts_list_photo"

invoke-static {[B][COLOR="Green"]v4[/COLOR][/B], [B][COLOR="Green"]v3[/COLOR][/B], [B][COLOR="Green"]v2[/COLOR][/B]}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result [B][COLOR="Green"]v4[/COLOR][/B]

Since .locals is for v variables only, so we can declare locals instead of .registers as following:

.method public xdaExampleMethod(IILandroid/content/Intent;)V
[B][COLOR="Red"].locals 5[/COLOR][/B]
.param [B][COLOR="Green"]p0[/COLOR][/B], "Lcom/sec/android/app/newApp"
.param [B][COLOR="Green"]p1[/COLOR][/B], ""id" # I"
.param [B][COLOR="Green"]p2[/COLOR][/B], "title" # I
.param [B][COLOR="Green"]p3[/COLOR][/B], "activity"

.prologue
const/4 [B][COLOR="Green"]v0[/COLOR][/B], -0x1

const/4 [B][COLOR="Green"]v1[/COLOR][/B], 0x1

const/4 [B][COLOR="Green"]v2[/COLOR][/B], 0x0

iget-object [B][COLOR="Green"]v4[/COLOR][/B], [B][COLOR="Green"]p0[/COLOR][/B], Lcom/sec/android/app/newApp;->mContext:Landroid/content/Context;

invoke-virtual {[B][COLOR="Green"]v4[/COLOR][/B]}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object [B][COLOR="Green"]v4[/COLOR][/B]

const-string [B][COLOR="Green"]v3[/COLOR][/B], "contacts_list_photo"

invoke-static {[B][COLOR="Green"]v4[/COLOR][/B], [B][COLOR="Green"]v3[/COLOR][/B], [B][COLOR="Green"]v2[/COLOR][/B]}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result [B][COLOR="Green"]v4[/COLOR][/B]

So here .registers 9 = .locals 5

I hope this is going to be a good explanation :)