Disable the button ok in vs mode
#14
(11-21-2021, 05:42 PM)Vega Wrote: @ha and @l are tools in an ASM compiler to help with applying values of statements, variables, and macros to various instructions

.set InputManager_s_instance, 0x809bd70c

lis r3, InputManager_s_instance@ha
lwz r3, InputManager_s_instance@l (r3)

With the address of 0x809bd70c. If you split it in 'half' and try to execute the following instructions...
lis r3, 0x809B
lwz r3, 0xD70C (r3)

The compiler will reject it. The 0xD70C is not within the proper 16-bit signed range.

What @ha will do is adjust the value during compilation to comply with the 16-bit signed range. Thus the instructions end up like this...

lis r3, 0x809C #809B + 1
lwz r3, 0xFFFFD70C (r3) #Sign extend 0xD70C to comply with range

Now this will compile and load the r3 value from the correct spot originally specified in r3.

When using any instructions that treat its values as signed you wanna use @ha and @l. If you are using instructions that treat its values as logical you would instead use @h and @l.

@ha = Upper Half (+1 if necessary)
@h = Upper Half
@l = Lower Half (will be sign extended if used with @ha only when its necessary)
ok i fix this in my code and doesn't work

the code:
import dolphin_memory_engine as dolphin_memory

dolphin_memory.hook()

def lwz(a,b):
    i = hex(a+b)[2:]
    i = i[-8:]
    i = int(i,16)
    return dolphin_memory.read_word(i)
def stw(a,b,c):
    dolphin_memory.write_word(a+b,c)
def lhz(a,b):
    v = hex(lwz(a, b))[2:]
    return int(v[:4],16)
def ori(a,b):
    a = hex(a)[2:]
    b= hex(b)[2:]
    return int(a[:-len(b)]+b,16)
def sth(a,b,c):
    dolphin_memory.write_word(a+b,c)
   
def press_a():
    r3 = 0x809c0000
    r3 = lwz(r3, 0xFFFFD70C)
    r3 = lwz(r3, 0x8)
    r4 = lhz(r3, 0x20)
    r4 = ori(r4,0x1)
    r4 = lhz(r3, 0x20)
    print(hex(r3))

press_a()
Reply


Messages In This Thread
Disable the button ok in vs mode - by coco - 11-19-2021, 11:58 AM
RE: Disable the button ok in vs mode - by Vega - 11-19-2021, 04:18 PM
RE: Disable the button ok in vs mode - by coco - 11-19-2021, 05:31 PM
RE: Disable the button ok in vs mode - by coco - 11-20-2021, 10:17 AM
RE: Disable the button ok in vs mode - by Vega - 11-19-2021, 11:06 PM
RE: Disable the button ok in vs mode - by coco - 11-20-2021, 10:22 AM
RE: Disable the button ok in vs mode - by stebler - 11-20-2021, 06:18 PM
RE: Disable the button ok in vs mode - by coco - 11-21-2021, 12:25 PM
RE: Disable the button ok in vs mode - by Vega - 11-21-2021, 03:13 PM
RE: Disable the button ok in vs mode - by coco - 11-21-2021, 04:42 PM
RE: Disable the button ok in vs mode - by coco - 11-21-2021, 05:30 PM
RE: Disable the button ok in vs mode - by Vega - 11-21-2021, 05:42 PM
RE: Disable the button ok in vs mode - by coco - 11-21-2021, 05:51 PM
RE: Disable the button ok in vs mode - by Vega - 11-21-2021, 05:52 PM
RE: Disable the button ok in vs mode - by coco - 11-21-2021, 06:21 PM
RE: Disable the button ok in vs mode - by Vega - 11-21-2021, 10:31 PM
RE: Disable the button ok in vs mode - by Vega - 11-22-2021, 02:03 AM
RE: Disable the button ok in vs mode - by coco - 11-22-2021, 12:13 PM
RE: Disable the button ok in vs mode - by Vega - 11-22-2021, 03:35 PM
RE: Disable the button ok in vs mode - by coco - 11-22-2021, 06:19 PM
RE: Disable the button ok in vs mode - by Vega - 11-22-2021, 06:59 PM
RE: Disable the button ok in vs mode - by coco - 11-22-2021, 07:03 PM

Forum Jump:


Users browsing this thread: 8 Guest(s)