WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: Bully@Wiiplaza on June 16, 2011, 07:39:27 PM

Title: RAM Write template
Post by: Bully@Wiiplaza on June 16, 2011, 07:39:27 PM
... for that instruction: lwzx   r3,r3,r0
Can someone help please?
Everything I tried froze the game... :-[
Title: Re: RAM Write template
Post by: Deathwolf on June 16, 2011, 07:49:01 PM
this instruction is fail! it should be lwzx r3,r0,rX
Title: Re: RAM Write template
Post by: Bully@Wiiplaza on June 16, 2011, 08:34:12 PM
Quote from: Deathwolf on June 16, 2011, 07:49:01 PM
this instruction is fail! it should be lwzx r3,r0,rX
no it´s not fail.
I need a template for this one.
Title: Re: RAM Write template
Post by: dcx2 on June 17, 2011, 12:04:13 AM
Quote from: Deathwolf on June 16, 2011, 07:49:01 PM
this instruction is fail! it should be lwzx r3,r0,rX

That is fail.  All instructions that load values from memory (lwz, lwzx, lwzu, lhz, lbz, etc) are (rA|0) instructions.

http://pds.twi.tudelft.nl/vakken/in101/labcourse/instruction-set/lwzx.html

If you use r0 as rA, it does not use the value in r0, instead it uses the value 0.

lwzx r3,r0,r3 = lwz r3,(r3 + 0), regardless of the contents of r0.

lwzx r3,r3,r0 = lwz r3,(r3 + r0)

---

To answer Bully's question,

li r12,0x63
stwx r12,r3,r0
lwzx r3,r3,r0
Title: Re: RAM Write template
Post by: Bully@Wiiplaza on June 18, 2011, 11:19:56 PM
Quote from: dcx2 on June 17, 2011, 12:04:13 AM
To answer Bully's question,

li r12,0xXX
stwx r12,r3,r0
lwzx r3,r3,r0
thought this fails... because I tried this template to load into r12, but the game froze.
Maybe I made another mistake or the game wouldn´t take that value? (that´s what I need to find out by myself though)
Let´s dig out a little thread by me and ThomasLin.

http://wiird.l0nk.org/forum/index.php/topic,8223.msg69083.html#msg69083

There ThomasLin told me how he did a RAM Write on a lwzx rX,rY,rX instruction that was about the same template you mentioned.
But it´s probably another case.

EDIT:

Does it also mean that you could do this...

lis r11, 0xVVVV
ori r11, r11, 0xWWWW
stw r11, Y (rX)
lwz rX,Y(rX)


instead of:

stwu r1, -16 (r1)
stw r11, 8 (r1)
lis r11, 0xVVVV
ori r11, r11, 0xWWWW
stw r11, Y (rX)
lwz r11, 8 (r1)
addi r1, r1, 16
lwz rX, Y (rX)
Title: Re: RAM Write template
Post by: dcx2 on June 18, 2011, 11:23:52 PM
It's possible the game doesn't like the change you're making with r12.

As always, it helps to post some disassembly.  No one rule will work every time, and sometimes different areas require exceptions to rules.
Title: Re: RAM Write template
Post by: Bully@Wiiplaza on June 18, 2011, 11:27:04 PM
it liked the change of r12, it just crashed because of r0 or r3, can´t remember.
However: I edited my post above.

---

EDIT:
the template works, only the game still freezes, because it´s executed for too many addresses :D