Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does JMP do to stack and frame pointers?

Tags:

x86

assembly

When an assembly has an instruction like jmp f what happens to the stack and frame pointers?

I mean - f is a label in memory right? How can we jump to different address in memory and not update our frame and stack pointers...

EDIT: I am talking about Intel x86 assembly yes :)

like image 950
Andriy Drozdyuk Avatar asked Mar 17 '10 20:03

Andriy Drozdyuk


1 Answers

The stack and frame pointers deal with location of the data. jmp instructions deal with location of the code. Unless something drastic happens, one should not affect the other. Here's a list of drastic things:

  • Task switches - due to a far jump using a task gate
  • faults - due to a jump to a new page that is invalid, or jumping out of the current segment, or a jmp that tries to change the privilege illegally.
  • traps - for instance, due to a code breakpoint. In fact, no other trap comes to mind at the moment.

That's about it. Even those cases change the stack because they involve some sort of context switch, either to a new task or to some exception handler.

Note also that no OS that I know of uses the CPU's task switching features. It's usually implemented in software.

like image 172
Nathan Fellman Avatar answered Oct 19 '22 14:10

Nathan Fellman