[Galaxy S II Android Development] majdinj:
Compiling with .registers > 16

I just want to give some hint when compiling with registers > 16,,, Yup it could be a problem unless you know the principle here.

Basically, parameter registers can't be invoked if they are stored in greater value than 16 ( i.e, v15 here)..

So what you need to do, is to move these parameter registers to a lower register values before invoking..

Taking the above method as example, you will need 5 registers to move parameters into them (p0-p4), then you need 3 registers for your mod modification; that makes 8 new registers in total.

So .registers 14 will be .registers 22

Now your new local registers will be from v9 to v16

Then move parameters to the new local registers lower than v16 (v0 to v15).. So:

p0 = v9

p1 = v10

p2 = v11

p3 = v12

p4 = v13

move-object/from16 v9, p0
move-object/from16 v10, p1
move-object/from16 v11, p2
move-object/from16 v12, p3
move-object/from16 v13, p4

Then, search the method and change all p0 to v9, p1 to v10, p2 to v11, p3 to v12, and p4 to v13

Finally, you can use your new 3 local registers (v14, v15, v16) in your method for the new mod.

So the final scheme of the new registers will be:

v9 = moved p0

v10 = moved p1

v11 = moved p2

v12 = moved p3

v13 = moved p4

v14 = new register for modding

v15 = new register for modding

v16 = new register for modding

v17 = original p0

v18 = original p1

v19 = original p2

v20 = original p3

v21 = original p4

So the method will look like this:

.method public create(Landroid/content/Context;Landroid/view/View;Landroid/view/ViewGroup;Landroid/view/LayoutInflater;)Landroid/view/View;
.registers 22
.parameter "context"
.parameter "convertView"
.parameter "parent"
.parameter "inflater"

.prologue
move-object/from16 v9, p0

move-object/from16 v10, p1

move-object/from16 v11, p2

move-object/from16 v12, p3

move-object/from16 v13, p4

const/4 v7, 0x0

.line 836
invoke-virtual {v9}, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->willCreate()V

.line 838
const v6, 0x1090045

invoke-virtual {v13, v6, v12, v7}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

move-result-object v5

.line 841
.local v5, v:Landroid/view/View;
const v6, 0x1020006

invoke-virtual {v5, v6}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v1

check-cast v1, Landroid/widget/ImageView;

.line 842
.local v1, icon:Landroid/widget/ImageView;
const v6, 0x102000b

invoke-virtual {v5, v6}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v2

check-cast v2, Landroid/widget/TextView;

.line 843
.local v2, messageView:Landroid/widget/TextView;
const v6, 0x10202a6

invoke-virtual {v5, v6}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v4

check-cast v4, Landroid/widget/TextView;

.line 844
.local v4, statusView:Landroid/widget/TextView;
invoke-virtual {v9}, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->isEnabled()Z

move-result v0

.line 846
.local v0, enabled:Z
if-eqz v2, :cond_34

.line 847
iget v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mMessageResId:I

invoke-virtual {v2, v6}, Landroid/widget/TextView;->setText(I)V

.line 848
invoke-virtual {v2, v0}, Landroid/widget/TextView;->setEnabled(Z)V

.line 851
:cond_34
iget-object v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v8, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->On:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

if-eq v6, v8, :cond_40

iget-object v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v8, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->TurningOn:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

if-ne v6, v8, :cond_68

:cond_40
const/4 v3, 0x1

.line 852
.local v3, on:Z
:goto_41
if-eqz v1, :cond_55

.line 853
invoke-virtual {v10}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

move-result-object v8

if-eqz v3, :cond_6a

iget v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mEnabledIconResId:I

:goto_4b
invoke-virtual {v8, v6}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

move-result-object v6

invoke-virtual {v1, v6}, Landroid/widget/ImageView;->setImageDrawable(Landroid/graphics/drawable/Drawable;)V

.line 855
invoke-virtual {v1, v0}, Landroid/view/View;->setEnabled(Z)V

.line 858
:cond_55
if-eqz v4, :cond_64

.line 859
if-eqz v3, :cond_6d

iget v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mEnabledStatusMessageResId:I

:goto_5b
invoke-virtual {v4, v6}, Landroid/widget/TextView;->setText(I)V

.line 860
invoke-virtual {v4, v7}, Landroid/view/View;->setVisibility(I)V

.line 861
invoke-virtual {v4, v0}, Landroid/widget/TextView;->setEnabled(Z)V

.line 863
:cond_64
invoke-virtual {v5, v0}, Landroid/view/View;->setEnabled(Z)V

.line 865
return-object v5

.end local v3 #on:Z
:cond_68
move v3, v7

.line 851
goto :goto_41

.line 853
.restart local v3 #on:Z
:cond_6a
iget v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mDisabledIconResid:I

goto :goto_4b

.line 859
:cond_6d
iget v6, v9, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->mDisabledStatusMessageResId:I

goto :goto_5b
.end method

Always Always try to re-use registers.. it will be much much easier.. but some times you will be forced to increase .registers to more than 16 where the problem will start during compiling unless you move your parameter registers into lower register values from v0 to v15..

I hope that will make it clear,, at least the principle behind it,,

Hope me a good luck in my research project for my final year residency program,, :eek:

Cheers,,,