ASM code help

Started by goemon_guy, August 02, 2010, 03:46:20 PM

Previous topic - Next topic

goemon_guy

I have been trying to make an infinite health code for some time now, and whenever I try to write it using ASM, it just crashes the game. Any suggestions?

I bet I am completely doing something wrong, or have misunderstood an instruction. >_<

Anyways, Here's the assembled code, and the unassembled code.

Infinite HP
C20EC868 00000003
7C00E800 40820004
9003006C 60000000
60000000 00000000


ADDRESS : 800ec868

cmpw r0,r29 # Compare registers r0 and r29
bne- 0x04 # If not equal, skip the next instruction
stw r0,108(r3) #Original instruction, store r0 to r3 + 108
nop # Do nothing

-Currently hacking the following game(s):
...
Request a code via PM, if you wish.

Deathwolf

#1
you can write it with lis and ori.
it writes 32 bit.

lis r12,0xXXXX
ori r12,r12,0xXXXX
stw r12,------ <-- instruction
-------------- <-- original full intruction.

example on this:

Infinity Health [Deathwolf]
C203CAE8 00000003
3D800000 618C0BB8
919F0030 807F0030
60000000 00000000

code:

lis r12,0x0000
ori r12,r12,0x0BB8
stw r12,48(r31)
lwz r3,48(r31)
nop

lwz r3,48(r31) is the original instruction.

or you write it only with li!
li= 0000XXXX

new code:
C203CAE8 00000002
3D800BB8 919F0030
807F0030 00000000

li r12,0x0BB8
stw r12,48(r31)
lwz r3,48(r31)



lolz

dcx2

branch destinations are relative to the branch itself.

For instance, b 0x00 would be an infinite loop, constantly branching to itself.  b 0x04 moves on to the next instruction, much like a nop (but nop is preferred for "do nothing", as branching has some performance implications inside a modern superscalar pipelined CPU)

In order to skip the next instruction, you must use b 0x08.  (and by b, I mean any branch, conditional or not)

Alternatively, download and install PyiiASMH and you can use branch labels to never calculate a branch offset ever again!

---

I took a closer look, and I'm not sure exactly what you're trying to do.  What is the significance of r29?  What's the disassembly around the hook address?  (both before and after)

Even still, your code shouldn't crash.  Regardless of the result of the cmpw, stw is always executed.  Unless your hook is between another comp and it's branch...

When the game crashes, go to the Breakpoint tab and hit "Get BP Data".  Copy and paste the registers/disasm and we can see why you're freezing.

goemon_guy

The significance of r29 was a compare. Whenever I was getting hit, they would both be the same. When I hit an enemy, they were always different.

So, I set a compare for it to only execute when they are equal.

And if not, then to just skip the next command.
-Currently hacking the following game(s):
...
Request a code via PM, if you wish.

dcx2

Hey, you seem to be pretty good at this already, if you're putting conditionals into your ASM.  ^_^

Without the disassembly, from about 800EC840-800EC880, I won't be able to give you much more help.  Like I said, bne- 0x04 is the same as a nop, so your code shouldn't really be crashing.

Are you applying C2 codes more than once?  Sometimes, WiiRDGUI will freeze after the first C2 code is applied.  So if you change the C2 and apply it again, that might be why it's freezing.

goemon_guy

Until I can get on my Wii, I won't be able to offer the disassembly code.

Also, I can note that the code no longer crashes the game. However, it just doesnt work at all. :S
>_<
-Currently hacking the following game(s):
...
Request a code via PM, if you wish.

dcx2

yeah, bne- 0x04 is like a nop; it doesn't skip any instructions.  You wanted bne- 0x08; that will skip the stw.

goemon_guy

Huh. Thats weird... When I changed the bne- 0x04 to 0x08, it still didnt work... In fact, it made all of my enemies invincible, and not me... *sigh*
-Currently hacking the following game(s):
...
Request a code via PM, if you wish.

dcx2

oh, haha, I didn't even think of that.  You want to branch over the store when r0 == r29.  Therefore, you want beq- instead of bne-.

goemon_guy

#9
Ah, OK.
I'll have to test that one later when I get on my Wii.

EDIT: I tested it, It worked perfectly, with an extra twist. It makes all the enemies die in one hit too! :D

Thanks for your help, dcx2!
-Currently hacking the following game(s):
...
Request a code via PM, if you wish.