This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: error in variable dereferencing


Thibaud GUERIN writes:
 > On 4/21/06, Andrew Haley <aph@gcc.gnu.org> wrote:
 > > Thibaud GUERIN writes:
 > >  > >
 > >
 > > OK, so we've got rid of the asms and casting away const, and the code
 > > still doesn't work.
 > >
 > > So, your code is now, at last, legal C.  Let's have a look at the
 > > assembly code generated for my_own_printf (use gcc -S).  Be sure to
 > > include the exact command line you used.

 > my_own_printf:

Args are just below sp.

 > 	pushl	%ebp
 > 	movl	%esp, %ebp

ebp points to:  frame, retaddr, arg0

 > 	subl	$8, %esp
 > 	leal	8(%ebp), %eax

eax contains ebp+8: it points to arg0

 > 	movl	%eax, -4(%ebp)

save eax on the stack

 > 	movl	-4(%ebp), %eax

restore it

 > 	movl	(%eax), %eax

load eax from arg0

 > 	cmpl	8(%ebp), %eax

compare eax with the memory at ebp+8

 > 	jne	.L33

So, the memory word at ebp+8 is compared with the memory at ebp+8.

Do you have a debuuger that can single-step through this code, one
insn at a time?

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]