summaryrefslogtreecommitdiff
path: root/src/prolog.S
blob: 09aaa7853f8a3950679796709302b6473646f60f (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
66
67
68
69
70
71
.text
.align 4
.set sp, 1

.extern __ctor_loc
.extern __ctor_end
.extern OSReport

.global Prolog
Prolog:
	stwu sp, -0x20(sp)
	mflr r0
	stw r0, 0x24(sp)
	stw r31, 0x1C(sp)
	stw r30, 0x18(sp)
	stw r29, 0x14(sp)
	# -- Go!

	li r30, 0

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

	lis r3, PMsg@h
	ori r3, r3, PMsg@l
	mr r4, r31
	mr r5, r29
	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)
	cmpw r31, r29
	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, 0x1C(sp)
	lwz r30, 0x18(sp)
	lwz r29, 0x14(sp)
	lwz r0, 0x24(sp)
	mtlr r0
	addi sp, sp, 0x20
	blr


.data
PMsg:
	.string "Newer Super Mario Bros. Wii - Hacks by Treeki and Tempus 2009-2013\nNewer Release Candidate 04 - v1011\n.ctors: %p - %p\n"

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

.align 4