WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: CosmoCortney on June 13, 2015, 04:26:14 AM



Title: cmpwi; blt: Clarification needed
Post by: CosmoCortney on June 13, 2015, 04:26:14 AM
Hi,
I'm have made an assembly code to permanently store a value if another value is smaller than 0xA00.
If it is greater than 0XA00 another (default) value is written.

The problem is that the comparison does not seem to be working properly.

Code:
.
.
.
lis r8, 0x803D /* load address of the growing
ori r8, r8, 0x1F48    integer into r8 */
lwz r10, 0 (r8) // load growing Int from address in r8 (803D1F48) into r10
lis r8, 0x804C /* load address
ori r8, r8, 0xB4EC    i want to write at */
cmpwi cr7, r10, 0xA00   // Compare r10 with 0xA00 ?
blt- 0x800035A4 // goto 800035A4 if r10 is lower than 0xA00 ?
lis r9, 0x3B40
.
.
.


when r10 is lower than 0xa00 the execution does not jump to 800035A4.
Any idea what's wrong here?


Title: Re: cmpwi; blt: Clarification needed
Post by: wiiztec on June 14, 2015, 01:56:33 PM
You need to use the same condition register as the compare for the branch.
so blt- cr7,0x800035A4


Title: Re: cmpwi; blt: Clarification needed
Post by: CosmoCortney on June 15, 2015, 05:16:51 PM
You need to use the same condition register as the compare for the branch.
so blt- cr7,0x800035A4


Already tried that. But nothing happened. Removing "cr7" from the syntax solved the problem