[Ffmpeg-devel] Stack alignment
ramiro at lisha.ufsc.br
ramiro
Thu Feb 22 16:21:36 CET 2007
Hey,
This is quite interesting...
--------------------------------------------------------------------------------
$ cat > alignment.c << EOF
> int check_alignment()
> {
> __declspec(align(16)) int aligned;
> return ((int)&aligned) & 15;
> }
> EOF
$ cl -c -O2 alignment.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for
80x86
Copyright (C) Microsoft Corporation. All rights reserved.
alignment.c
$ objdump -d alignment.obj
alignment.obj: file format pe-i386
Disassembly of section .text:
00000000 <_check_alignment>:
0: 55 push %ebp
1: 8b ec mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 8d 44 24 f0 lea 0xfffffff0(%esp),%eax
a: 83 ec 10 sub $0x10,%esp
d: 83 e0 0f and $0xf,%eax
10: 8b e5 mov %ebp,%esp
12: 5d pop %ebp
13: c3 ret
--------------------------------------------------------------------------------
I had always wondered why this stupid, broken, bloated compiler for such
an obscure system (which should never be used by any *real* programmer)
did that at line 3: of the disassembly.
Well, I guess Microsoft's compiler is just aligning its stack variables...
I wonder for how long it has been doing this... Anyone with olders
versions (eg: VC6) care to test too?
Ramiro Polla
More information about the ffmpeg-devel
mailing list