summaryrefslogtreecommitdiff
path: root/arm9/asm/MSL_Common_ansi_files.s
blob: a2e75c22058ec46ce8db07733762066ed8479097 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	.include "global.inc"
	.include "asm/macros.inc"

	.data

	.global __files
__files: ; 0x02106A58
	; stdin
	.byte 0x00, 0x00, 0x00, 0x00, 0x24, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.word stdin_buff
	.byte 0x00, 0x01, 0x00, 0x00
	.word stdin_buff
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.word __read_console
	.word __write_console
	.word __close_console
	.byte 0x00, 0x00, 0x00, 0x00

	; stdout
	.byte 0x01, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.word stdout_buff
	.byte 0x00, 0x01, 0x00, 0x00
	.word stdout_buff
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.word __read_console
	.word __write_console
	.word __close_console
	.byte 0x00, 0x00, 0x00, 0x00

	; stderr
	.byte 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.word stderr_buff
	.byte 0x00, 0x01, 0x00, 0x00
	.word stderr_buff
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
	.word __read_console
	.word __write_console
	.word __close_console
	.byte 0x00, 0x00, 0x00, 0x00
	.size __files,.-__files

	.bss

	.global stderr_buff
stderr_buff: ; 0x021D71A8
	.space 0x100
	.size stderr_buff,.-stderr_buff

	.global stdout_buff
stdout_buff: ; 0x021D72A8
	.space 0x100
	.size stdout_buff,.-stdout_buff

	.global stdin_buff
stdin_buff: ; 0x021D73A8
	.space 0x100
	.size stdin_buff,.-stdin_buff

	.text

	arm_func_start __flush_line_buffered_output_files
__flush_line_buffered_output_files:
	stmdb sp!, {r3-r9,lr}
	ldr r0, _020DE384 ; =__files
	mov r4, #0x0
	mov r5, #0x1
	mov r8, r0
	mvn r9, #0x0
	mov r7, r4
	mov r6, #0x4c
_020DE31C:
	ldr r1, [r0, #0x4]
	mov r2, r1, lsl #0x16
	movs r2, r2, lsr #0x1d
	beq _020DE35C
	mov r1, r1, lsl #0x19
	mov r1, r1, lsr #0x1e
	tst r1, #0x1
	beq _020DE35C
	ldr r1, [r0, #0x8]
	mov r1, r1, lsl #0x1d
	mov r1, r1, lsr #0x1d
	cmp r1, #0x1
	bne _020DE35C
	bl fflush
	cmp r0, #0x0
	movne r4, r9
_020DE35C:
	cmp r5, #0x3
	movge r0, r7
	bge _020DE374
	mul r0, r5, r6
	add r5, r5, #0x1
	add r0, r8, r0
_020DE374:
	cmp r0, #0x0
	bne _020DE31C
	mov r0, r4
	ldmia sp!, {r3-r9,pc}
	.balign 4
_020DE384: .word __files
	arm_func_end __flush_line_buffered_output_files

	arm_func_start __flush_all
__flush_all: ; 0x020DE388
	stmdb sp!, {r3-r9,lr}
	ldr r0, _020DE3EC ; =__files
	mov r4, #0x0
	mov r5, #0x1
	mov r8, r0
	mvn r9, #0x0
	mov r7, r4
	mov r6, #0x4c
_020DE3A8:
	ldr r1, [r0, #0x4]
	mov r1, r1, lsl #0x16
	movs r1, r1, lsr #0x1d
	beq _020DE3C4
	bl fflush
	cmp r0, #0x0
	movne r4, r9
_020DE3C4:
	cmp r5, #0x3
	movge r0, r7
	bge _020DE3DC
	mul r0, r5, r6
	add r5, r5, #0x1
	add r0, r8, r0
_020DE3DC:
	cmp r0, #0x0
	bne _020DE3A8
	mov r0, r4
	ldmia sp!, {r3-r9,pc}
	.balign 4
_020DE3EC: .word __files
	arm_func_end __flush_all

	exception __flush_line_buffered_output_files, 141, 0x00403F00
	exception __flush_all, 105, 0x00403F00