what does JMP do to stack and frame pointers?

assembly, x86

Solution

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.

Problem

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 :)

Original source