Floating Value in ASM C2

Started by Deathwolf, July 18, 2010, 11:45:41 AM

Previous topic - Next topic

Deathwolf

please give me a example to activate
lolz

dcx2

try decimal 11111111 = hex 0x00A98AC7


Deathwolf

lolz

Deathwolf

oh my bad.

sry wrong address.

8005F62C:  808DA620   lwz   r4,-23008(r13)

lis r12,0x00A9
ori r12,r12,0x8AC7
stw r12,-23008(r13)
lwz   r4,-23008(r13)

C205F62C 00000003
3D8000A9 618C8AC7
918DA620 808DA620
60000000 00000000

now it works
lolz

Deathwolf

80941A34:  889F0001   lbz   r4,1(r31)

lis r12,0x2C00
ori r12,r12,0x0000
stw r12,1(r31)
lbz   r4,1(r31)

C2941A34 00000003
3D802C00 618C0000
919F0001 889F0001
60000000 00000000

it wont change full 32bit.

it writes: 002C0000 o,o

help pls
lolz

dcx2

80941A34:  889F0001   lbz   r4,1(r31)

lis r12,0x2C00              ^
ori r12,r12,0x0000         |
stw r12,1(r31)  <-------
lbz   r4,1(r31)

w = word = 32 bits
b = byte = 8 bits

---

problem 2 - alignment

A word = 32 bits must be "word aligned".  The address must be a multiple of 4.  (i.e. 80000000, 80000004, 80000008, 8000000C, 80000010, 80000014, etc).

Look again at your stw.  stw r12,1(r31)  The offset of 1 is fail, because the address 1(r31) is not a multiple of 4.  That's why you must use stb instead of stw.

---

li r12, 0x2C
stb r12,1(r31)
lbz   r4,1(r31)

Deathwolf

#36
thank you very much for your help dcx2 :)
but it's the same.
it change 002C0000
lolz

dcx2

Yes.  stb with 1(r31) is 00xx0000.

stb
0(31) = xx000000
1(31) = 00xx0000
2(31) = 0000xx00
3(31) = 000000xx


stw 0(r31) = xxxxxxxx


sth 0(r31) = xxxx0000
sth 2(r31) = 0000xxxx

Deathwolf

hmm okay but what happens if I change the lbz to lwz?
lwz=XXXXXXXX

li r12,0x2C
stw r12,1(r31)
lwz   r4,1(r31)
lolz

James0x57

Like he said about alignment,
stw r12,1(r31) -> stw r12,0(r31)



whoops, nvm!


dcx2

Quote from: Deathwolf on July 19, 2010, 05:34:08 PM
hmm okay but what happens if I change the lbz to lwz?
Fail happens.

Quote
stw r12,1(r31)
lwz   r4,1(r31)

alignment fail

Deathwolf

#41
r0
and
r1

lis r12,0x2C00
ori r12,r12,0x000
stw r12,0(r31) = 32 bit
lwz r4,1(r31)

code:

C2941A34 00000003
3D80ZZ00 618C0000
919F0000 809F0001
60000000 00000000
lolz

dcx2

lwz r4,1(r31)

alignment fail

---

also, changing lbz -> lwz will probably fail

Deathwolf

#43
lis r12,0x2C00
ori r12,r12,0x000
stw r12,0(r31) = 32 bit
lwz r4,1(r31)

this code works.

but this:

lis r12,0x2C00
ori r12,r12,0x000
stw r12,0(r31) = 32 bit
lwz r4,0(r31)

freez

maybe you mean:

lis r12,0x2C00
ori r12,r12,0x000
stw r12,0(r31) = 32 bit
lbz r4,0(r31)
lolz

dcx2

lwz r4,1(r31) will might work, but it still fails alignment.  I'm surprised it would work with 1(r31) and freeze with 0(r31).  WiiRDGUI will sometimes freeze if you apply C2 codes more than once.

---

What are you trying to do?  If the game was using lbz, use stb.  If the game was using lwz, use stw.  Why change lbz to lwz?  Using the wrong alignment will cause problems.