| 1 |
/* |
| 2 |
decode_i586: asm synth |
| 3 |
|
| 4 |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
| 5 |
see COPYING and AUTHORS files in distribution or http://mpg123.org |
| 6 |
initially written by Stefan Bieschewski |
| 7 |
|
| 8 |
synth_1to1 works the same way as the c version of this |
| 9 |
file. only two types of changes have been made: |
| 10 |
- reordered floating point instructions to |
| 11 |
prevent pipline stalls |
| 12 |
- made WRITE_SAMPLE use integer instead of |
| 13 |
(slower) floating point |
| 14 |
all kinds of x86 processors should benefit from these |
| 15 |
modifications. |
| 16 |
|
| 17 |
useful sources of information on optimizing x86 code include: |
| 18 |
|
| 19 |
Intel Architecture Optimization Manual |
| 20 |
http://www.intel.com/design/pentium/manuals/242816.htm |
| 21 |
|
| 22 |
Cyrix 6x86 Instruction Set Summary |
| 23 |
ftp://ftp.cyrix.com/6x86/6x-dbch6.pdf |
| 24 |
|
| 25 |
AMD-K5 Processor Software Development |
| 26 |
http://www.amd.com/products/cpg/techdocs/appnotes/20007e.pdf |
| 27 |
|
| 28 |
Stefan Bieschewski <[email protected]> |
| 29 |
|
| 30 |
$Id: decode_i586.s 1 2004-09-18 13:30:08Z thomas $ |
| 31 |
*/ |
| 32 |
|
| 33 |
#include "mangle.h" |
| 34 |
|
| 35 |
RODATA |
| 36 |
ALIGN8 |
| 37 |
.LC0: |
| 38 |
.long 0x0,0x40dfffc0 |
| 39 |
ALIGN8 |
| 40 |
.LC1: |
| 41 |
.long 0x0,0xc0e00000 |
| 42 |
ALIGN8 |
| 43 |
.text |
| 44 |
/* int synth_1to1_i586_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin); */ |
| 45 |
.globl ASM_NAME(INT123_synth_1to1_i586_asm) |
| 46 |
ASM_NAME(INT123_synth_1to1_i586_asm): |
| 47 |
subl $12,%esp |
| 48 |
pushl %ebp |
| 49 |
pushl %edi |
| 50 |
pushl %esi |
| 51 |
pushl %ebx |
| 52 |
/* stack: 0=ebx, 4=esi, 8=edi, 12=ebp, 16,20,24=local, 28=back, 32=bandPtr, 36=channel, 40=out, 44=buffs, 48=bo, 52=decwin */ |
| 53 |
movl 32(%esp),%eax /* *bandPtr */ |
| 54 |
movl 40(%esp),%esi /* *out */ |
| 55 |
movl 48(%esp),%edi /* *bo */ |
| 56 |
movl (%edi),%ebp /* store bo value in ebp */ |
| 57 |
xorl %edi,%edi |
| 58 |
cmpl %edi,36(%esp) |
| 59 |
jne .L48 /* if(!channel) */ |
| 60 |
decl %ebp /* bo-- */ |
| 61 |
andl $15,%ebp /* bo &= 0xf */ |
| 62 |
movl 48(%esp), %edi /* *bo */ |
| 63 |
movl %ebp,(%edi) /* write back bo */ |
| 64 |
xorl %edi,%edi /* restore %edi to 0; it's used later */ |
| 65 |
movl 44(%esp),%ecx /* use buffs */ |
| 66 |
jmp .L49 |
| 67 |
.L48: /* if(channel) use buffs+2176 */ |
| 68 |
addl $2,%esi |
| 69 |
movl 44(%esp),%ecx /* *buffs */ |
| 70 |
addl $2176,%ecx |
| 71 |
.L49: |
| 72 |
testl $1,%ebp |
| 73 |
je .L50 |
| 74 |
movl %ecx,%ebx |
| 75 |
movl %ebp,16(%esp) |
| 76 |
pushl %eax |
| 77 |
movl 20(%esp),%edx |
| 78 |
leal (%ebx,%edx,4),%eax |
| 79 |
pushl %eax |
| 80 |
movl 24(%esp),%eax |
| 81 |
incl %eax |
| 82 |
andl $15,%eax |
| 83 |
leal 1088(,%eax,4),%eax |
| 84 |
addl %ebx,%eax |
| 85 |
jmp .L74 |
| 86 |
.L50: |
| 87 |
leal 1088(%ecx),%ebx |
| 88 |
leal 1(%ebp),%edx |
| 89 |
movl %edx,16(%esp) |
| 90 |
pushl %eax |
| 91 |
leal 1092(%ecx,%ebp,4),%eax |
| 92 |
pushl %eax |
| 93 |
leal (%ecx,%ebp,4),%eax |
| 94 |
.L74: |
| 95 |
pushl %eax |
| 96 |
call FUNC(INT123_dct64_i386) |
| 97 |
addl $12,%esp |
| 98 |
/* stack now back on track */ |
| 99 |
movl 16(%esp),%edx |
| 100 |
leal 0(,%edx,4),%edx |
| 101 |
movl 52(%esp),%eax /* decwin */ |
| 102 |
addl $64,%eax |
| 103 |
movl %eax,%ecx |
| 104 |
subl %edx,%ecx |
| 105 |
movl $16,%ebp |
| 106 |
.L55: |
| 107 |
flds (%ecx) |
| 108 |
fmuls (%ebx) |
| 109 |
flds 4(%ecx) |
| 110 |
fmuls 4(%ebx) |
| 111 |
fxch %st(1) |
| 112 |
flds 8(%ecx) |
| 113 |
fmuls 8(%ebx) |
| 114 |
fxch %st(2) |
| 115 |
fsubrp %st,%st(1) |
| 116 |
flds 12(%ecx) |
| 117 |
fmuls 12(%ebx) |
| 118 |
fxch %st(2) |
| 119 |
faddp %st,%st(1) |
| 120 |
flds 16(%ecx) |
| 121 |
fmuls 16(%ebx) |
| 122 |
fxch %st(2) |
| 123 |
fsubrp %st,%st(1) |
| 124 |
flds 20(%ecx) |
| 125 |
fmuls 20(%ebx) |
| 126 |
fxch %st(2) |
| 127 |
faddp %st,%st(1) |
| 128 |
flds 24(%ecx) |
| 129 |
fmuls 24(%ebx) |
| 130 |
fxch %st(2) |
| 131 |
fsubrp %st,%st(1) |
| 132 |
flds 28(%ecx) |
| 133 |
fmuls 28(%ebx) |
| 134 |
fxch %st(2) |
| 135 |
faddp %st,%st(1) |
| 136 |
flds 32(%ecx) |
| 137 |
fmuls 32(%ebx) |
| 138 |
fxch %st(2) |
| 139 |
fsubrp %st,%st(1) |
| 140 |
flds 36(%ecx) |
| 141 |
fmuls 36(%ebx) |
| 142 |
fxch %st(2) |
| 143 |
faddp %st,%st(1) |
| 144 |
flds 40(%ecx) |
| 145 |
fmuls 40(%ebx) |
| 146 |
fxch %st(2) |
| 147 |
fsubrp %st,%st(1) |
| 148 |
flds 44(%ecx) |
| 149 |
fmuls 44(%ebx) |
| 150 |
fxch %st(2) |
| 151 |
faddp %st,%st(1) |
| 152 |
flds 48(%ecx) |
| 153 |
fmuls 48(%ebx) |
| 154 |
fxch %st(2) |
| 155 |
fsubrp %st,%st(1) |
| 156 |
flds 52(%ecx) |
| 157 |
fmuls 52(%ebx) |
| 158 |
fxch %st(2) |
| 159 |
faddp %st,%st(1) |
| 160 |
flds 56(%ecx) |
| 161 |
fmuls 56(%ebx) |
| 162 |
fxch %st(2) |
| 163 |
fsubrp %st,%st(1) |
| 164 |
flds 60(%ecx) |
| 165 |
fmuls 60(%ebx) |
| 166 |
fxch %st(2) |
| 167 |
subl $4,%esp |
| 168 |
faddp %st,%st(1) |
| 169 |
fxch %st(1) |
| 170 |
fsubrp %st,%st(1) |
| 171 |
fistpl (%esp) |
| 172 |
popl %eax |
| 173 |
cmpl $32767,%eax |
| 174 |
jg 1f |
| 175 |
cmpl $-32768,%eax |
| 176 |
jl 2f |
| 177 |
movw %ax,(%esi) |
| 178 |
jmp 4f |
| 179 |
1: movw $32767,(%esi) |
| 180 |
jmp 3f |
| 181 |
2: movw $-32768,(%esi) |
| 182 |
3: incl %edi |
| 183 |
4: |
| 184 |
.L54: |
| 185 |
addl $64,%ebx |
| 186 |
subl $-128,%ecx |
| 187 |
addl $4,%esi |
| 188 |
decl %ebp |
| 189 |
jnz .L55 |
| 190 |
flds (%ecx) |
| 191 |
fmuls (%ebx) |
| 192 |
flds 8(%ecx) |
| 193 |
fmuls 8(%ebx) |
| 194 |
flds 16(%ecx) |
| 195 |
fmuls 16(%ebx) |
| 196 |
fxch %st(2) |
| 197 |
faddp %st,%st(1) |
| 198 |
flds 24(%ecx) |
| 199 |
fmuls 24(%ebx) |
| 200 |
fxch %st(2) |
| 201 |
faddp %st,%st(1) |
| 202 |
flds 32(%ecx) |
| 203 |
fmuls 32(%ebx) |
| 204 |
fxch %st(2) |
| 205 |
faddp %st,%st(1) |
| 206 |
flds 40(%ecx) |
| 207 |
fmuls 40(%ebx) |
| 208 |
fxch %st(2) |
| 209 |
faddp %st,%st(1) |
| 210 |
flds 48(%ecx) |
| 211 |
fmuls 48(%ebx) |
| 212 |
fxch %st(2) |
| 213 |
faddp %st,%st(1) |
| 214 |
flds 56(%ecx) |
| 215 |
fmuls 56(%ebx) |
| 216 |
fxch %st(2) |
| 217 |
subl $4,%esp |
| 218 |
faddp %st,%st(1) |
| 219 |
fxch %st(1) |
| 220 |
faddp %st,%st(1) |
| 221 |
fistpl (%esp) |
| 222 |
popl %eax |
| 223 |
cmpl $32767,%eax |
| 224 |
jg 1f |
| 225 |
cmpl $-32768,%eax |
| 226 |
jl 2f |
| 227 |
movw %ax,(%esi) |
| 228 |
jmp 4f |
| 229 |
1: movw $32767,(%esi) |
| 230 |
jmp 3f |
| 231 |
2: movw $-32768,(%esi) |
| 232 |
3: incl %edi |
| 233 |
4: |
| 234 |
.L62: |
| 235 |
addl $-64,%ebx |
| 236 |
addl $4,%esi |
| 237 |
movl 16(%esp),%edx |
| 238 |
leal -128(%ecx,%edx,8),%ecx |
| 239 |
movl $15,%ebp |
| 240 |
.L68: |
| 241 |
flds -4(%ecx) |
| 242 |
fchs |
| 243 |
fmuls (%ebx) |
| 244 |
flds -8(%ecx) |
| 245 |
fmuls 4(%ebx) |
| 246 |
fxch %st(1) |
| 247 |
flds -12(%ecx) |
| 248 |
fmuls 8(%ebx) |
| 249 |
fxch %st(2) |
| 250 |
fsubrp %st,%st(1) |
| 251 |
flds -16(%ecx) |
| 252 |
fmuls 12(%ebx) |
| 253 |
fxch %st(2) |
| 254 |
fsubrp %st,%st(1) |
| 255 |
flds -20(%ecx) |
| 256 |
fmuls 16(%ebx) |
| 257 |
fxch %st(2) |
| 258 |
fsubrp %st,%st(1) |
| 259 |
flds -24(%ecx) |
| 260 |
fmuls 20(%ebx) |
| 261 |
fxch %st(2) |
| 262 |
fsubrp %st,%st(1) |
| 263 |
flds -28(%ecx) |
| 264 |
fmuls 24(%ebx) |
| 265 |
fxch %st(2) |
| 266 |
fsubrp %st,%st(1) |
| 267 |
flds -32(%ecx) |
| 268 |
fmuls 28(%ebx) |
| 269 |
fxch %st(2) |
| 270 |
fsubrp %st,%st(1) |
| 271 |
flds -36(%ecx) |
| 272 |
fmuls 32(%ebx) |
| 273 |
fxch %st(2) |
| 274 |
fsubrp %st,%st(1) |
| 275 |
flds -40(%ecx) |
| 276 |
fmuls 36(%ebx) |
| 277 |
fxch %st(2) |
| 278 |
fsubrp %st,%st(1) |
| 279 |
flds -44(%ecx) |
| 280 |
fmuls 40(%ebx) |
| 281 |
fxch %st(2) |
| 282 |
fsubrp %st,%st(1) |
| 283 |
flds -48(%ecx) |
| 284 |
fmuls 44(%ebx) |
| 285 |
fxch %st(2) |
| 286 |
fsubrp %st,%st(1) |
| 287 |
flds -52(%ecx) |
| 288 |
fmuls 48(%ebx) |
| 289 |
fxch %st(2) |
| 290 |
fsubrp %st,%st(1) |
| 291 |
flds -56(%ecx) |
| 292 |
fmuls 52(%ebx) |
| 293 |
fxch %st(2) |
| 294 |
fsubrp %st,%st(1) |
| 295 |
flds -60(%ecx) |
| 296 |
fmuls 56(%ebx) |
| 297 |
fxch %st(2) |
| 298 |
fsubrp %st,%st(1) |
| 299 |
flds (%ecx) |
| 300 |
fmuls 60(%ebx) |
| 301 |
fxch %st(2) |
| 302 |
subl $4,%esp |
| 303 |
fsubrp %st,%st(1) |
| 304 |
fxch %st(1) |
| 305 |
fsubrp %st,%st(1) |
| 306 |
fistpl (%esp) |
| 307 |
popl %eax |
| 308 |
cmpl $32767,%eax |
| 309 |
jg 1f |
| 310 |
cmpl $-32768,%eax |
| 311 |
jl 2f |
| 312 |
movw %ax,(%esi) |
| 313 |
jmp 4f |
| 314 |
1: movw $32767,(%esi) |
| 315 |
jmp 3f |
| 316 |
2: movw $-32768,(%esi) |
| 317 |
3: incl %edi |
| 318 |
4: |
| 319 |
.L67: |
| 320 |
addl $-64,%ebx |
| 321 |
addl $-128,%ecx |
| 322 |
addl $4,%esi |
| 323 |
decl %ebp |
| 324 |
jnz .L68 |
| 325 |
movl %edi,%eax |
| 326 |
popl %ebx |
| 327 |
popl %esi |
| 328 |
popl %edi |
| 329 |
popl %ebp |
| 330 |
addl $12,%esp |
| 331 |
ret |
| 332 |
|
| 333 |
#if defined(PIC) && defined(__APPLE__) |
| 334 |
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5 |
| 335 |
FUNC(INT123_dct64_i386): |
| 336 |
.indirect_symbol ASM_NAME(INT123_dct64_i386) |
| 337 |
hlt ; hlt ; hlt ; hlt ; hlt |
| 338 |
#endif |
| 339 |
|
| 340 |
NONEXEC_STACK |