11-21-2021, 05:42 PM
@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)
.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)