This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
assembler generated code
- From: san bangalore <sanbangalore at yahoo dot co dot in>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 31 Jan 2005 13:23:47 +0000 (GMT)
- Subject: assembler generated code
Hi All,
I am trying to figure out the assembly code generated
for a C++ source code. I have written a simple C++
program an d trying to match the generated assembly
code.
I am attaching a file which contains both the source
and the assembly code. I have also put my comments for
those assembly constructs which i could understand.
I could not understand 2 blocks of assembly code which
i have named as DOUBT1_start and DOUBT2_start.
Can anyone please explain me what the assembly code in
between the DOUBT label means.
Warm Regards,
San
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
/*
///////////////////C++ source code/////////////////
class A
{
public:
int i;
A(){ i = 100;
hello();
}
void hello() {};
};
int main()
{
A *temp1 = new A();
temp1->hello();
A *temp2 = new A();
}
*/
_main:
1:two.cpp **** class A
2:two.cpp **** {
3:two.cpp **** public:
4:two.cpp **** int i;
5:two.cpp **** A(){ i = 100;
6:two.cpp **** hello();
7:two.cpp **** }
8:two.cpp **** void hello() {};
9:two.cpp ****
10:two.cpp **** };
11:two.cpp ****
12:two.cpp ****
13:two.cpp **** int main()
14:two.cpp **** {
57 LM1:
58 0000 55 pushl %ebp
59 0001 89E5 movl %esp, %ebp
60 0003 57 pushl %edi
61 0004 56 pushl %esi
62 0005 53 pushl %ebx
63 0006 83EC6C subl $108, %esp
64 0009 83E4F0 andl $-16, %esp
65 000c B8000000 movl $0, %eax
65 00
66 0011 8945B8 movl %eax, -72(%ebp)
67 0014 8B45B8 movl -72(%ebp), %eax
68 0017 E8000000 call __alloca
68 00
69 001c C745D800 movl $___gxx_personality_sj0, -40(%ebp)
69 000000
70 0023 C745DC00 movl $LLSDA7, -36(%ebp)
70 000000
71 002a 8D45E0 leal -32(%ebp), %eax
72 002d 8D55F4 leal -12(%ebp), %edx
73 0030 8910 movl %edx, (%eax)
74 0032 BAF30000 movl $L14, %edx
74 00
75 0037 895004 movl %edx, 4(%eax)
76 003a 896008 movl %esp, 8(%eax)
77 003d 8D45C0 leal -64(%ebp), %eax
78 0040 890424 movl %eax, (%esp)
79 0043 E8000000 call __Unwind_SjLj_Register
79 00
80 0048 E8000000 call ___main
80 00
15:two.cpp ****
16:two.cpp **** A *temp1 = new A();
82 LM2:
83 LBB2:
84 004d C7042404 movl $4, (%esp)
84 000000
85 0054 C745C4FF movl $-1, -60(%ebp)
85 FFFFFF
86 005b E8000000 call __Znwj =====>call new operator
86 00
87 0060 8945B4 movl %eax, -76(%ebp)
88 0063 C645B301 movb $1, -77(%ebp)
89 0067 8B45B4 movl -76(%ebp), %eax
90 006a 890424 movl %eax, (%esp)
91 006d C745C402 movl $2, -60(%ebp)
91 000000
92 0074 E8000000 call __ZN1AC1Ev =====>call A::A()
92 00
93 0079 C645B300 movb $0, -77(%ebp)
94 007d 8B55B4 movl -76(%ebp), %edx
95 0080 8955F0 movl %edx, -16(%ebp) #temp1
96 0083 EB2F jmp L3
97 L2: ===============================================> DOUBT1_start
98 0085 8B45A8 movl -88(%ebp), %eax
99 0088 8945AC movl %eax, -84(%ebp)
100 008b 807DB300 cmpb $0, -77(%ebp)
101 008f 740B je L5
102 0091 8B55B4 movl -76(%ebp), %edx
103 0094 891424 movl %edx, (%esp)
104 0097 E8000000 call __ZdlPv =======> call operator delete
104 00
105 L5:
106 009c 8B45AC movl -84(%ebp), %eax
107 009f 8945A8 movl %eax, -88(%ebp)
108 L6:
109 00a2 8B55A8 movl -88(%ebp), %edx
110 00a5 891424 movl %edx, (%esp)
111 00a8 C745C4FF movl $-1, -60(%ebp)
111 FFFFFF
112 00af E8000000 call __Unwind_SjLj_Resume
112 00 ==========================================================> DOUBT1_end
113 L3:
17:two.cpp **** temp1->hello();
115 LM3:
116 00b4 8B45F0 movl -16(%ebp), %eax # temp1
117 00b7 890424 movl %eax, (%esp)
118 00ba E8000000 call __ZN1A5helloEv ======> call A::hello()
118 00
18:two.cpp **** A *temp2 = new A();
120 LM4:
121 00bf C7042404 movl $4, (%esp)
121 000000
122 00c6 C745C4FF movl $-1, -60(%ebp)
122 FFFFFF
123 00cd E8000000 call __Znwj ========> call new operator
123 00
124 00d2 8945A4 movl %eax, -92(%ebp)
125 00d5 C645A301 movb $1, -93(%ebp)
126 00d9 8B45A4 movl -92(%ebp), %eax
127 00dc 890424 movl %eax, (%esp)
128 00df C745C401 movl $1, -60(%ebp)
128 000000
129 00e6 E8000000 call __ZN1AC1Ev =========> call A::A()
129 00
130 00eb 8B55A4 movl -92(%ebp), %edx
131 00ee 8955EC movl %edx, -20(%ebp) # temp2
132 00f1 EB40 jmp L9
133 L14: ======================================================> DOUBT2_start
134 00f3 8D6D0C leal 12(%ebp), %ebp
135 00f6 8B45C4 movl -60(%ebp), %eax
136 00f9 8B55C8 movl -56(%ebp), %edx
137 00fc 8955A8 movl %edx, -88(%ebp)
138 00ff 83F801 cmpl $1, %eax
139 0102 7481 je L2
140 L8:
141 0104 8B45A8 movl -88(%ebp), %eax
142 0107 89459C movl %eax, -100(%ebp)
143 010a 807DA300 cmpb $0, -93(%ebp)
144 010e 740B je L11
145 0110 8B55A4 movl -92(%ebp), %edx
146 0113 891424 movl %edx, (%esp)
147 0116 E8000000 call __ZdlPv =====> call delete operator
147 00
148 L11:
149 011b 8B459C movl -100(%ebp), %eax
150 011e 8945A8 movl %eax, -88(%ebp)
151 L12:
152 0121 8B55A8 movl -88(%ebp), %edx
153 0124 891424 movl %edx, (%esp)
154 0127 C745C4FF movl $-1, -60(%ebp)
154 FFFFFF
155 012e E8000000 call __Unwind_SjLj_Resume
155 00 ============================================================> DOUBT2_end
156 L9:
19:two.cpp ****
20:two.cpp **** }
158 LM5:
159 LBE2:
160 0133 C745BC00 movl $0, -68(%ebp)
160 000000
161 L1:
162 013a 8D45C0 leal -64(%ebp), %eax
163 013d 890424 movl %eax, (%esp)
164 0140 E8000000 call __Unwind_SjLj_Unregister
164 00
165 0145 8B45BC movl -68(%ebp), %eax
166 0148 8D65F4 leal -12(%ebp), %esp
167 014b 5B popl %ebx
168 014c 5E popl %esi
169 014d 5F popl %edi
170 014e 5D popl %ebp
171 014f C3 ret
172 .section .gcc_except_table,"dr"
173 LLSDA7:
174 0000 FF .byte 0xff
175 0001 FF .byte 0xff
176 0002 01 .byte 0x1
177 0003 04 .uleb128 LLSDACSE7-LLSDACSB7
178 LLSDACSB7:
179 0004 00 .uleb128 0x0
180 0005 00 .uleb128 0x0
181 0006 01 .uleb128 0x1
182 0007 00 .uleb128 0x0
183 LLSDACSE7:
184 .text
189 Lscope0:
191 .section .text$_ZN1A5helloEv,"x"
192 .linkonce discard
193 .align 2
196 .globl __ZN1A5helloEv
198 __ZN1A5helloEv: ==================== hello()
200 LM6:
201 0000 55 pushl %ebp
202 0001 89E5 movl %esp, %ebp
204 LM7:
205 0003 5D popl %ebp
206 0004 C3 ret
207 Lscope1:
209 0005 909090 .section .text$_ZN1AC1Ev,"x"
210 .linkonce discard
211 .align 2
214 .globl __ZN1AC1Ev
216 __ZN1AC1Ev: ==============A::A()
218 LM8:
219 0000 55 pushl %ebp
220 0001 89E5 movl %esp, %ebp
221 0003 83EC08 subl $8, %esp
223 LM9:
224 LBB3:
225 0006 8B4508 movl 8(%ebp), %eax # this
226 0009 C7006400 movl $100, (%eax) # <variable>.i
226 0000
228 LM10:
229 000f 8B4508 movl 8(%ebp), %eax # this
230 0012 890424 movl %eax, (%esp)
231 0015 E8000000 call __ZN1A5helloEv =========> call hello()
231 00
233 LM11:
234 001a C9 leave
235 001b C3 ret
236 LBE3:
237 Lscope2:
239 .text
241 Letext: