summaryrefslogtreecommitdiff
path: root/src/prolog.S
blob: 1a988ec3be5ac95b190b0427d7645abf0a2f5b29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
.text
.align 4
.set sp, 1

.extern __ctor_loc
.extern OSReport

.global Prolog
Prolog:
	stwu sp, -0x10(sp)
	mflr r0
	stw r0, 0x14(sp)
	stw r31, 0xC(sp)
	stw r30, 0x8(sp)
	# -- Go!

	li r30, 0

	lis r31, __ctor_loc@h
	ori r31, r31, __ctor_loc@l

	lis r3, PMsg@h
	ori r3, r3, PMsg@l
	mr r4, r31
	crclr 4*cr1+eq
	bl OSReport

	b startLoop

loop:
	mtctr r12
	bctrl
	addi r31, r31, 4
	addi r30, r30, 1
startLoop:
	lwz r12, 0(r31)
	cmpwi r12, 0
	bne loop

	lis r3, PMsg2@h
	ori r3, r3, PMsg2@l
	mr r4, r30
	crclr 4*cr1+eq
	bl OSReport

	# -- Done
	li r3, 1
	lwz r31, 0xC(sp)
	lwz r30, 0x8(sp)
	lwz r0, 0x14(sp)
	mtlr r0
	addi sp, sp, 0x10
	blr


.data
PMsg:
	.string "Newer Super Mario Bros. Wii - Hacks by Treeki 2009-2011\n.ctors: %p\n"

PMsg2:
	.string "%d inits called\n"

.align 4