Hello,
title tells it all. I've been creating a codehandler for Wii U cheat codes for quite some time now. It's entirely written in PPC and does it's job very well. The programming was no problem to me until now:
I want to add a codetype that allows the user to execute any assembly code. The codehandler will execute it, so no certain address will be needed. The assembly code of the cheat is located 0x08 remote from the address inside of GPR6 (GPR6 always holds the address of the current/next cheat to be executed). The codetype would look like the following:
C000NNNN 00000000
XXXXXXXX XXXXXXXX
XXX....
C0 = The codetype's value
NNNN 0 number of assembly lines (one line has 2 assembly instructions)
XX... = asm
last assembly instruction should be blr or something else to go back to the codehandler
once the codehandler reads C0 as codetype it should branch the execution to r6 + 0x08.
Would this be a good solution?
addi r7, r6, 0x08
mtlr r7
blr
The problem is that now the value of lr is overwritten. So exiting the codehandler would get the execution into an infinite loop.
What about?
title tells it all. I've been creating a codehandler for Wii U cheat codes for quite some time now. It's entirely written in PPC and does it's job very well. The programming was no problem to me until now:
I want to add a codetype that allows the user to execute any assembly code. The codehandler will execute it, so no certain address will be needed. The assembly code of the cheat is located 0x08 remote from the address inside of GPR6 (GPR6 always holds the address of the current/next cheat to be executed). The codetype would look like the following:
C000NNNN 00000000
XXXXXXXX XXXXXXXX
XXX....
C0 = The codetype's value
NNNN 0 number of assembly lines (one line has 2 assembly instructions)
XX... = asm
last assembly instruction should be blr or something else to go back to the codehandler
once the codehandler reads C0 as codetype it should branch the execution to r6 + 0x08.
Would this be a good solution?
addi r7, r6, 0x08
mtlr r7
blr
The problem is that now the value of lr is overwritten. So exiting the codehandler would get the execution into an infinite loop.
What about?
Code:
at the codehandler: mflr r31 // backup lr into r31 addi r7, r6, 0x04 // get the location of assembly code (less 0x04) into r7 mtlr r7 // put r7 into lr blr // branch to lr + 4 at the end of the cheat code lis r7, 0xXXXX // load the location of the codehandler (where the blr is located) ori r7, r7, 0xXXX // " mtlr r7 // load this location into r7 blr // branch back to the codehandler +0x04 back at the codehandler mtlr r31 // reload r31 into lr so the program won't crash on return 0.

Comment