Using the Exception Vector Area in ASM Codes
#1
Using the Exception Vector Area in ASM Codes

If you have started making ASM Codes recently, you will eventually hit a point where you need to store values during one ASM code, to later utilize said values in another ASM Code. The simplest method to achieve that is to store the necessary data/values to what is known as the Exception Vector Area.

The Exception Vector Area is universal (same location within memory) for every Wii Game. It is unused areas of memory next to the Exception Handler subroutines. Here are the address ranges:

NOTE! You may find these ranges to not be accurate if you are viewing the Game's memory from Dolphin. However, on the Wii Console, these are the correct ranges which are tighter (less room to work with) than what appears on Dolphin.

Oh ye another note: These were taken when running a CLEAN MKW ISO (no patches). Various patching could effect these ranges.

Safe ranges to use:
0x800001B0 thru 0x800001FF
0x800002B0 thru 0x800002FF
0x800003B0 thru 0x800003FF
0x800004B0 thru 0x800004FF
0x800005B0 thru 0x800005FF
0x800006B0 thru 0x800006FF
0x800007B0 thru 0x800007FF
0x800008B0 thru 0x800008FF
0x800009B0 thru 0x80000BFF
0x80000CB0 thru 0x80000CFF
0x80000DB0 thru 0x80000EFF
0x80000FB0 thru 0x80000FFF
0x800011C0 thru 0x800012FF
0x800013B0 thru 0x800013FF
0x800014B0 thru 0x800016FF
0x800017B0 thru 0x800017FF


These areas are safe to write to. Keep in mind that many ASM codes utilize the 0x800014B0 thru 0x800016FF range. So it is best to pick a different area to use, as you don't want to end up using the same exact location in memory as another code.

Here's a simple code showing how to utilize the Exception Vector Area...

http://mkwii.com/showthread.php?tid=889

The first ASM code has a register that holds the value of the in-race room size. We want to use this value for the next ASM Code (shared item code) to help determine whether or not the code should execute. When the shared item code gets executed, there are no registers that hold the in-race room size value. 

So what the 1st instruction of the 1st ASM code does is establish the 1st half address of the Vector Area (lis r12, 0x8000). The next instruction stores the in-race room size value (byte) to the designated spot in the Vector Area at 0x8000164F. Now this allows the second ASM to load this byte value into a register for use.

As you can see, pretty simple to do. Happy coding!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)