Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > Assembly Language
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Assembly Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 1st, 2007, 02:43 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Questions about the pointer registers

I'm a new learner of assembly language. When I learned about the pointer registers of Intel IA-32 processors, I've got the questions below:

1)In Intel IA-32 Platform, the processor usually have EBP as "Stack data pointer" and ESP as "Stack pointer", what's the difference between these two registers?

2)I have read the assembly source below:
...
pushl $buffer
pushl $output
call printf
addl $8, %esp
...
Why add 0x8 to register ESP after call "printf"?

Can anybody do me a fever? Thanks.

  #2 (permalink)  
Old April 30th, 2007, 11:21 PM
Wrox Author
 
Join Date: Dec 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

#1 EBP is also commonly refered to as the Frame Pointer.

ESP is the only one that gets automatically incremented / decremented by the CPU when you call, ret, or push and pop stuff.

EBP is usually only used by a compiler to keep track of the current frame its working with. EBP or the Frame Pointer then becomes a usefull shortcut for all kinds of things.

#2 adding 8 to esp is a simple way to remove the two values pushed onto the stack before calling printf.

With a compiler in the mix, then you could see several variations of this calling convention based on the calling convention for the function being called. In this case printf isnt doing any stack cleanup, so the caller has to do it after printf returns.

Steve Wort
Co Author "Professional SQL Server 2005 Administration"





Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to struct goscho C++ Programming 1 January 10th, 2008 07:23 AM
Pointer fReqZz C++ Programming 5 June 5th, 2007 01:09 AM
Pointer reference perstam C++ Programming 5 April 29th, 2006 08:51 AM
NULL Pointer kumar_raj13 C++ Programming 0 July 15th, 2005 01:10 AM
pointer-to-function in C++ jacob C++ Programming 2 October 23rd, 2004 05:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.