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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
.text
;.section text,__TEXT
.globl _ppc_zoom ;// name of the function to call by C program
; notes :
; this routine dynamically computes and applies a zoom filter
; do not use r0, r1, r2 and r3
; registers are not saved so the call to this function must be the last thing done in the calling C function
; parameters :
; r3 <=> unsigned int * frompixmap
; r4 <=> unsigned int * topixmap
; r5 <=> unsigned int sizeX (in pixels)
; r6 <=> unsigned int sizeY (in pixels)
; r7 <=> unsigned int * brutS
; r8 <=> unsigned int * brutD
; r9 <=> unsigned int buffratio
; r10 <=> int [16][16] precalccoeffs
; globals after init
; r3 <=> frompixmap - 1 byte needed for preincremental fetch (replaces r3)
; r4 <=> topixmap - 1 byte needed for preincremental fetch (replaces r4)
; r5 <=> ax = x max in 16th of pixels (replaces old r5)
; r6 <=> ay = y max in 16th of pixels (replaces old r6)
; r15 <=> row size in bytes
; r16 <=> 0xFF00FF (mask for parallel 32 bits pixs computing)
; r30 <=> brutS - 1 byte needed for preincremental fetch (replaces r7)
; r31 <=> brutD - 1 byte needed for preincremental fetch (replaces r8)
; free reg
; r13
; r18
_ppc_zoom: ; symbole global sur lequel on va linker
; avant tout, on va sauver les registres
stw r13,-76(r1)
stw r14,-72(r1)
stw r15,-68(r1)
stw r16,-64(r1)
stw r17,-60(r1)
stw r18,-56(r1)
stw r19,-52(r1)
stw r20,-48(r1)
stw r21,-44(r1)
stw r22,-40(r1)
stw r23,-36(r1)
stw r24,-32(r1)
stw r25,-28(r1)
stw r26,-24(r1)
stw r27,-20(r1)
stw r28,-16(r1)
stw r29,-12(r1)
stw r30,-8(r1)
stw r31,-4(r1)
; init
dcbt 0,r8
li r14,0 ; valeur par defaut si out of range : 0 (Noir)
mr r11,r10
lis r16,0xFF
mullw r17,r5,r6 ; calcul du nombre de pixels a faire
dcbt 0,r7
subi r30,r8,4
mulli r15,r5,4
srawi r19,r15,2
ori r16,r16,0xFF
subi r5,r5,1
subi r6,r6,1
mtspr ctr,r17 ; on met le nombre de pixels a faire dans le compteur de la boucle
subi r31,r7,4
subi r4,r4,4
mulli r5,r5,16
mulli r6,r6,16
li r13,32
;pre init for loop
lwzu r17,4(r31) ; px
lwzu r8,4(r30) ; px2
lwzu r10,4(r30) ; py2
1:
lwzu r29,4(r31) ; py
; computes dynamically the position to fetch
sub r8,r8,r17
sub r10,r10,r29
mullw r8,r8,r9
mullw r10,r10,r9
srawi r8,r8,16
srawi r10,r10,16
add r17,r17,r8
add r29,r29,r10
; if px>ax or py>ay goto outofrange
cmpl cr1,0,r17,r5
; computes the attenuation coeffs and the original point address
andi. r10,r29,0x0F ;coefv
cmpl cr2,0,r29,r6
andi. r8,r17,0x0F ;coefh
srawi r29,r29,4 ; pos computing
bgt- cr1,Loutofrange
srawi r17,r17,4 ; pos computing
mulli r10,r10,4
bgt- cr2,Loutofrange
mullw r29, r29,r19 ; pos computing
; NOTA : notation des couches : 00112233 (AARRVVBB)
mulli r8,r8,4*16
add r17,r17,r29 ; pos computing
add r10,r10,r8
slwi r17,r17,2 ; pos computing
add r10,r10,r11
dcbt 0,r10
add r17,r17,r3 ; pos computing
lwz r10,0(r10) ; chargement des coefs
dcbt 0,r17
andi. r21,r10,0xFF ; isolation du coef1
srwi r10,r10,8 ; isolation du coeff2 etape 1/2
lwz r25,0(r17) ; chargement de col1 ->r25
andi. r22,r10,0xFF ; isolation du coef2 etape 2/2
srwi r10,r10,8 ; isolation du coef3 etape 1/2
and r8, r25,r16 ; masquage de col1 couches 1 & 3 : 0x00XX00XX
lwz r26,4(r17) ; chargement de col2 ->r26
andi. r23,r10,0xFF ; isolation du coef3 etape 2/2
mullw r8, r8, r21 ; application du coef1 sur col1 couches 1 & 3
srwi r10,r10,8 ; isolation du coef4 etape 1/2
andi. r25,r25,0xFF00 ; masquage de col1 couche 2 : 0x0000XX00
add r17,r17,r15 ; ajout d'une ligne pour chargement futur de col3
dcbt 0,r17
andi. r24,r10,0xFF ; isolation du coef4 etape 2/2
; computes final pixel color
and r10,r26,r16 ; masquage de col2 couches 1 & 3 : 0x00XX00XX
lwz r27,0(r17) ; chargement de col3 ->r27
mullw r25,r25,r21 ; application du coef1 sur col1 couche 2
mullw r10,r10,r22 ; application du coef2 sur col2 couches 1 & 3
andi. r29,r26,0xFF00 ; masquage de col2 couche 2 : 0x0000XX00
lwz r28,4(r17) ; chargement de col4 ->r28
add r8 ,r8 ,r10 ; ajout de col1 & col2 couches 1 & 3
mullw r29,r29,r22 ; application du coef2 sur col2 couche 2
and r10,r27,r16 ; masquage de col3 couches 1 & 3 : 0x00XX00XX
add r25,r25,r29 ; ajout de col1 & col2 couche 2
mullw r10,r10,r23 ; application du coef3 sur col3 couches 1 & 3
andi. r29,r27,0xFF00 ; masquage de col3 couche 2 : 0x0000XX00
add r8 ,r8 ,r10 ; ajout de col3 à (col1 + col2) couches 1 & 3
mullw r29,r29,r23 ; application du coef3 sur col3 couche 2
and r10,r28,r16 ; masquage de col4 couches 1 & 3 : 0x00XX00XX
add r25,r25,r29 ; ajout de col 3 à (col1 + col2) couche 2
mullw r10,r10,r24 ; application du coef4 sur col4 couches 1 & 3
andi. r28,r28,0xFF00 ; masquage de col4 couche 2 : 0x0000XX00
add r8 ,r8 ,r10 ; ajout de col4 à (col1 + col2 + col3) couches 1 & 3
lwzu r17,4(r31) ; px
dcbt 0,r31
mullw r28,r28,r24 ; application du coef4 sur col4 couche 2
srawi r7, r8, 8 ; (somme des couches 1 & 3) >> 8
add r25,r25,r28 ; ajout de col 4 à (col1 + col2 + col3) couche 2
lwzu r8,4(r30) ; px2
and r7, r7, r16 ; masquage de la valeur résiduelle dans le résultat des couches 1 & 3
srawi r25, r25, 8 ; (somme des couches 2) >> 8
lwzu r10,4(r30) ; py2
andi. r25,r25,0xFF00 ; masquage de la valeur résiduelle dans le résultat des couches 2
or r7, r25, r7 ; association des couches (1 & 3) et 2
stwu r7,4(r4) ; stockage du résultat final
bdnz+ 1boucle ; itération suivante si besoin
b Lend;goto end ; sinon sortie de boucle pour fin
; if out of range
Loutofrange:
stwu r14,4(r4)
dcbtst r13,r4 ;touch for store
lwzu r8,4(r30) ; px2
lwzu r10,4(r30) ; py2
lwzu r17,4(r31) ; px
bdnz+ 1boucle
Lend: ; Fin de la routine, on restore les registres utilisés entre 13 et 31
lwz r14,-76(r1)
lwz r14,-72(r1)
lwz r15,-68(r1)
lwz r16,-64(r1)
lwz r17,-60(r1)
lwz r18,-56(r1)
lwz r19,-52(r1)
lwz r20,-48(r1)
lwz r21,-44(r1)
lwz r22,-40(r1)
lwz r23,-36(r1)
lwz r24,-32(r1)
lwz r25,-28(r1)
lwz r26,-24(r1)
lwz r27,-20(r1)
lwz r28,-16(r1)
lwz r29,-12(r1)
lwz r30,-8(r1)
lwz r31,-4(r1)
blr ; et on retourne
|