Question

ATT syntax.

I've noticed that library routines in C often use the following snippet of assembly code:

call next
next:
popl %eax
  • What value is %eax storing here and why is it getting popped?
  • What's the purpose of this snippet?
Was it helpful?

Solution 2

What is the value of %eax after this sequence of instructions?

call next

next: popl %eax

Whatever the address of next is

(the memory address where popl instruction is) Note: this is NOT the PC, but it is related to it

– PC is the address of the next instruction to be executed; %eax now has address of most recently executed instruction (the popl)

See

OTHER TIPS

It gives you the current value of the program counter (PC). That is, you get the address of the current instruction that is executing.

Here's an interesting article that talks about using that snippet vs doing it with C: http://blogs.msdn.com/b/oldnewthing/archive/2004/12/16/317157.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top