LEGO Indiana Jones
[savezelda.git] / lego / exploit.s
1 # Copyright 2008-2009  Segher Boessenkool  <segher@kernel.crashing.org>
2 # This code is licensed to you under the terms of the GNU GPL, version 2;
3 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
4
5         .section .start,"ax"
6
7 start:
8         # Set up a stack frame.
9         lis 1,0x8080 ; li 0,0 ; stwu 0,-64(1)
10
11         # Stop audio and video.
12         lis 0,audio_stop@h ; ori 0,0,audio_stop@l ; mtctr 0 ; bctrl
13         lis 0,video_stop@h ; ori 0,0,video_stop@l ; mtctr 0 ; bctrl
14
15         # Move code into place; a generous 32kB, starting at 64kB in
16         # the save file.
17
18         lis 3,main@h ; ori 3,3,main@l ; addi 5,3,-4
19         lis 4,0x806c ; lwz 4,0xdc48-0x10000(4) ; addi 4,4,-4
20         addis 4,4,1 ; addi 4,4,end-start
21         li 0,0x2000 ; mtctr 0
22 0:      lwzu 0,4(4) ; stwu 0,4(5) ; bdnz 0b
23
24         # Sync caches on it.
25         li 0,0x0400 ; mtctr 0 ; mr 5,3
26 0:      dcbst 0,5 ; sync ; icbi 0,5 ; addi 5,5,0x20 ; bdnz 0b
27         sync ; isync
28
29         # Go for it!
30         mtctr 3 ; bctr
31 end: