ASM Activators [Clay10]

If you're looking to replace a normal 28/20 button activator with an ASM button activator, this is how.


First, open up PyiiASMh or ASM <->WiiRD (For ASM <->WiiRD, note that you will need to change the codetype to C0 and remove the base address). I will be using PyiiASMh.


As always, you will want to clear registers 14-30.

Next, you will load your button activator address into a register. I will be using r12. SPECIAL NOTE - Button activators that are made using a 16-bit search will not work with ASM. To find the real button activator address, just search for a button activator as you normally would, but use a 32-bit search instead. I have found 0x80206028 as the real button activator address for MW3.


To load your button activator address into a register, you would use simple lis/ori as you would with any other code.

After that, we will use a lwz instruction to load the 32-bit value at 0x80206028 into r12. (make sure the lwz is loading into the same register as the address for the button activator is in)

So far we have loaded our button activator address into a register, and loaded the value from that address into the same register. Now, we will use the instruction "cmplwi", which stands for "Compare Logical Word Immediate".

What this does is compare the word in r12 to 0x8000 (home button value). After this comparison, we will need to branch. So if we want the code to activate if 0x80206028 equals 0x8000, we will use the beq instruction, which stands for Branch if Equal to. Now, there is a nifty little way to branch using PyiiASMh or ASM <->WiiRD.

In this screenshot, you can see that it will branch if r12 is equal to 0x8000. The program will automatically calculate the branch distance to "ON". So when it branches, it will do the operation of "ON", which in this case happens to load the address for CompassSize into r15, and store 0x40000000 to that address. Now as always, we will need to pop r14-30 back onto the stack.

But this will not work. This code will only freeze your wii or just not function properly. At the end of each instruction "group", you need to branch to the group of "popping r14-30 back onto the stack". (for lack of better words, by "group" I mean group of instructions. I have the group of instructions loading the button activator and comparing the values, I have the ON group if r12 is equal to 0x8000, and I have the group that pops r14-30 back onto the stack)

As you can see here, I have labeled "lmw r14,8(r1) addi r1,r1,80" as END. After each code group, they will branch to the group END, which will complete the code by popping r14-30 back onto the stack.

Heres the code:

stwu r1,-80(r1)

stmw r14,8(r1)

lis r12,0xAAAA

ori r12,r12,0xBBBB

lwz r12,0(r12)

cmplwi r12,0xCCCC

beq- ON

b END


ON:

lis r15,0xDDDD

ori r15,r15,0xEEEE

lis r14,0xFFFF

ori r14,r14,0xGGGG

stw r14,0(r15)

b END


END:

lmw r14,8(r1)

addi r1,r1,80


AAAA = First 4 digits of Activator

BBBB = Last 4 digits of Activator

CCCC = Button Value

DDDD = First 4 digits of Address you're writing to

EEEE = Last 4 digits of Address you're writing to

FFFF = First 4 digits of the value you're writing

GGGG = Last 4 digits of the value you're writing