WiiRd Community
September 09, 2010, 07:21:57 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Update 4.3 - do NOT update!


Gecko 1.9.3.1
Should I get a USB Gecko, I wanna hack?
How do I use my USB Gecko
Where can I get WiiRd?
 
   Home   CODE DATABASE Help Search Login Register  
Pages: [1]
  Print  
Author Topic: (ASM) Store/load from an address instead of a register?  (Read 217 times)
polyesterday
Newbie
*

Karma: 0
Posts: 17


View Profile
« on: June 19, 2010, 06:41:51 pm »

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)?
Logged
wiiztec
Lazy hacking machine
Hacker
Hero Member
*****

Karma: 19
Posts: 521

TimmyKitty7124
View Profile WWW
« Reply #1 on: June 20, 2010, 01: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)
Logged

If there's any code at all that you want to be button activated, or even able to toggle on & off, and I have the game, just PM me and I'll make it happen
dcx2
Computer Engineer
Moderator
Hero Member
*****

Karma: 61
Posts: 1125


View Profile WWW
« Reply #2 on: June 20, 2010, 02:15:39 am »

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 to convert ASM to C2 codes.
Logged

polyesterday
Newbie
*

Karma: 0
Posts: 17


View Profile
« Reply #3 on: June 20, 2010, 08:54:50 am »

Excellent, thanks guys. Pardon my ignorance, I'm still kind of overwhelmed with how robust WiiRd is.
Logged
Romaap
Hacker
Moderator
Legendary Member
*****

Karma: 80
Posts: 1803


View Profile WWW
« Reply #4 on: June 20, 2010, 07:54:04 pm »

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 Wink
Logged
wiiztec
Lazy hacking machine
Hacker
Hero Member
*****

Karma: 19
Posts: 521

TimmyKitty7124
View Profile WWW
« Reply #5 on: June 20, 2010, 09:11:41 pm »

no shit
Logged

If there's any code at all that you want to be button activated, or even able to toggle on & off, and I have the game, just PM me and I'll make it happen
Romaap
Hacker
Moderator
Legendary Member
*****

Karma: 80
Posts: 1803


View Profile WWW
« Reply #6 on: June 20, 2010, 10:26:33 pm »

...

oops, I misunderstood what you said, sorry Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!