lsw: JPN fix
[savezelda.git] / lsw / exploit.s
1 # Copyright 2008-2009  Segher Boessenkool  <segher@kernel.crashing.org>
2 # Copyright      2011  roto <roto@mozy.org>
3 # This code is licensed to you under the terms of the GNU GPL, version 2;
4 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
5
6         .section .start,"ax"
7
8 start:
9         # Set up a stack frame.
10         lis 1,0x8080 ; li 0,0 ; stwu 0,-64(1)
11
12         # Stop audio and video.
13         lis 0,audio_stop@h ; ori 0,0,audio_stop@l ; mtctr 0 ; bctrl
14         lis 0,video_stop@h ; ori 0,0,video_stop@l ; mtctr 0 ; bctrl
15
16         # Move code into place; a generous 32kB, starting at 64kB in
17         # the save file.
18
19         # Load address where we're going to move our exploit code to
20         # (0x90000020) into R03
21         lis 3,main@h ; ori 3,3,main@l ; addi 5,3,-4
22
23         # Load the address for the beginning of our save data
24         # (0x91168ea0) into R04
25         lis 4,save@h ; ori 4,4,save@l ; addi 4,4,-4
26
27         addis 4,4,1 ; addi 4,4,end-start
28         li 0,0x2000 ; mtctr 0
29 0:      lwzu 0,4(4) ; stwu 0,4(5) ; bdnz 0b
30
31         # Sync caches on it.
32         li 0,0x0400 ; mtctr 0 ; mr 5,3
33 0:      dcbst 0,5 ; sync ; icbi 0,5 ; addi 5,5,0x20 ; bdnz 0b
34         sync ; isync
35
36         # Jump to 0x90000020 and go for it!
37         mtctr 3 ; bctr
38 end: