Do I have to backup the values of registers when using Execute ASM codes?

Started by AlexWong, August 06, 2010, 08:45:10 AM

Previous topic - Next topic

AlexWong

Execute ASM
C0000000 NNNNNNNN
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ ZZZZZZZZ
4E800020 00000000

Executes the NNNNNNNN lines of instruction placed under the code.
The instructions MUST end with a blr (0x4E800020).

Do I have to backup the values of registers such as r0, r1, r2 and so on? Or will WiiRd automatically backup the registers?
Unsatisfied w/o cheats.

Deathwolf

r0 safe
r1 Stack pointer
r2 Table of Contents (TOC) pointer
r3 safe
r4 not safe
r5 safe
r6 ba
r7 gr addresses
r8 code execution status
r9 safe
r10 safe
r11 safe
r12 safe
r13 not safe (reserved)
r14 safe
r15 code line address
r16 not used
r17 safe
r18 safe
r19 safe
r20 po
r21-r31 unknown

C0 codetype is not for ASM instructions.
only for RAM writes like 04 codetypes.

example:

042DE6C8 FFFFFFFF
042DE6D0 01010101

in C0:

lis r12,0x802D <--- load into address 802DE6C8
ori r12,r12,0xE6C8
lis r0,0xFFFF <--- write value FFFFFFFF
ori r0,r0,0xFFFF
stw r0,0,(r12) <--- store to address 802DE6C8
lis r0,0x0101
ori r0,r0,0x0101 <-- write value 01010101
stw r0,16,(r12) <-- store to address 802DE6D0



lolz

AlexWong

So I can use r0, r3, r5, r9, r10, r11, r12, r14, r17, r18 and r19 as I like. Thank you. :smileyface:
I can use C0 code type to form lots of other code types. I knew how to use it on PSP platform cheat plugin: CM Fuision. 8)
Unsatisfied w/o cheats.

biolizard89

Quote from: Deathwolf on August 06, 2010, 01:31:19 PM
C0 codetype is not for ASM instructions.
only for RAM writes like 04 codetypes.

example:

042DE6C8 FFFFFFFF
042DE6D0 01010101
Umm, C0 is for ASM instructions.  They just get executed during the code handler rather than a custom hook.  Yes, they're typically used for RAM writes, but that's what most ASM is typically used for (what does any code do other than writing to RAM in some way?).

(I assume AlexWong already knows this; I just want to avoid confusing other people who read this thread.)

Deathwolf

sure u can use every instruction. (ASM etc.)

but this works with RAM writes too.
lolz

AlexWong

Oh I forgot to ask that which float type registers I can use safely. ;D
Unsatisfied w/o cheats.

dcx2

In my post on the safety of registers http://wiird.l0nk.org/forum/index.php/topic,6555.0.html

There's a link to the PowerPC Embedded Application Binary Interface (PPC EABI).  http://www.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF77852569970071B0D6/$file/eabi_app.pdf

Using the datasheet above, you'll see that F13-F9 (in order of safety) are volatile and not used for passing parameters or return values, so they should be the ultimate in safety.  F8-F2 (again in order of safety) are the next safest; they're volatile, but will sometimes be used to pass parameters into the function.  F1 is probably the least safe, because it's used for input parameters and return values.  But in a C0 code F1 would probably still work too.  Now, a C2 code is a different matter entirely...

AlexWong

Unsatisfied w/o cheats.