LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2014, 08:31 AM   #1
v3ct0r
Member
 
Registered: Jun 2013
Location: China
Distribution: Archlinux
Posts: 67

Rep: Reputation: Disabled
Question assembly ebp, esp problem


Hey guys, I have a little weird quesion here about the first three lines instrunctions goes as a function starts excuting.
A tipical example in ATT assembly
Code:
pushl %ebp           ;%ebp -> -4(%esp), %esp <- %esp -4
movl %esp, %ebp      ;%ebp <- %esp, ther
movl 8(%ebp), %eax
let's assume that %ebp is 0x100 as initial, and %esp is 0x64, the first line makes %esp to 0x60, then the second line makes %ebp to 0x60, where the third line is going to get m(0x68) data to %eax, but %eax should get m(%108)...
But definitely I'm lost in a rabbit hole, where I'm a wrong at this.
 
Old 03-16-2014, 08:54 AM   #2
v3ct0r
Member
 
Registered: Jun 2013
Location: China
Distribution: Archlinux
Posts: 67

Original Poster
Rep: Reputation: Disabled
Damn it, I know what the point, it turns out after invoke, before the
Code:
movl %esp, %ebp
%ebp is still the frame pointer of last function, but after that, ebp becomes the current frame pointer, while the arguments is exactly on the 4n+4(%ebp).

So in general, %ebp is like a guard for memory, which cares about all local variable's address. program uses %ebp to infer arg and local var.
And %ebp is stable in a function.
All the arguments have to be in stack before invoke a function.
I'm far too 'new' to assembly, what a shame

Last edited by v3ct0r; 03-16-2014 at 09:05 AM.
 
  


Reply

Tags
assembly



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Linux Assembly: write and receive assembly data errigour Programming 2 09-22-2012 09:54 AM
Assembly Problem - Help Needed calciferfelix Programming 10 05-19-2011 03:10 PM
Assembly - little problem with ret cdog Programming 6 05-11-2007 03:35 PM
imho weird assembly problem Robattack Programming 0 12-07-2006 06:47 PM
another problem in assembly usr Programming 1 01-31-2004 01:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration