Is there a way to load or store something to a register from a specified address instead of another register?
IE can I make a function sort of like stb 0x8079DAA0,4(r3) instead of stb r0,4(r3)?
You obviously misunderstand ASM stb r0,4(r3) writes the byte value contained in r0 to the address at r3+the offset 4
if you want to store the byte at the address 8079DAA0 to r3 you would do this
lis rX,0x8079
ori rX,rX,0xdaa0
lbz r3,0(rX)
The PowerPC processor does not support operations directly on memory. You need to use a combination of loads and stores. You will need to over-write a register with the address that you want to load/store, and then use that register with the load/store. Make sure that the register you're over-writing is safe; when in doubt, r12 is pretty safe. But, for example, if the game needs an important pointer in r3, and you start over-writing r3, it will lose that important pointer and crash.
Here's an example that will do what I think you want to do.
lis r12,0x8079 # Load the upper 16 bits of r12 with 8079
ori r12,r12,0xDAA0 # Load the lower 16 bits of r12 with DAA0
lbz r12,0(r12) # Load the 8 bits at address 8079DAA0 into r12
stb r12,4(r3) # Store those 8 bits to address 4(r3)
Now, how to add this to the game? You would have to over-write four consecutive instructions to make this happen, but you probably only have one instruction that you can replace, the stb r0. This is a problem.
And the C2 code type is our problem solver. It will over-write the stb r0 with a single instruction, but that instruction will be a branch that goes to the four instructions above, and it will then branch back. Just make sure you add the instruction you replaced (the stb r0) to the C2 code (which we did, with the stb r12). It's an easy thing to forget and will end up causing you grief sooner or later.
By the way, use PyiiASMH (http://code.google.com/p/pyiiasmh/) to convert ASM to C2 codes.
Excellent, thanks guys. Pardon my ignorance, I'm still kind of overwhelmed with how robust WiiRd is.
Quote from: wiiztec on June 20, 2010, 02:58:10 AM
You obviously misunderstand ASM stb r0,4(r3) writes the byte value contained in r0 to the address at r3+the offset 4
if you want to store the byte at the address 8079DAA0 to r3 you would do this
lis rX,0x8079
ori rX,rX,0xdaa0
lbz r3,0(rX)
That would load the value at that address to r3 ;)
no shit
...
oops, I misunderstood what you said, sorry :)