Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > Assembly Language
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 1st, 2007, 02:43 AM
Registered User
Join Date: Mar 2007
Location: Shanghai, , China.
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
Location: kirkland, wa, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

#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"

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 09:34 AM.

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