x86 stack-frame to stack-frame move
From: Frode Vatvedt Fjeld (frodef_at_cs.uit.no)
Date: 02/19/04
- Next message: The Passer-by: "Re: MsDos COM file format"
- Previous message: Gerhard W. Gruber: "Re: kernel"
- Next in thread: Matt Taylor: "Re: x86 stack-frame to stack-frame move"
- Reply: Matt Taylor: "Re: x86 stack-frame to stack-frame move"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 19 Feb 2004 18:54:41 +0000 (UTC)
[I posted this first in comp.arch, and someone suggested I might ask
this question here on comp.lang.asm.x86.]
>>From a (recent) x86 compiler perspective, what's the best way to copy
one stack-frame location to another? For example, to copy location
(ebp -8) to (ebp -12):
mov eax (ebp -8)
mov (ebp -12) eax
Now, assuming you don't need the contents of (ebp -8) for anything
else, will this be equally effective?
push (ebp -8)
pop (ebp -12)
In the first example, assuming again that the following instructions
will break any dependencies on eax, I believe the CPU will assign eax
to some virtual scratch register. The question is, will this also
happen with the second example? If the two versions are equally
efficient, the second is preferrable since it frees up eax (or some
other gp register) for other use.
So I suppose my question is this: can I expect recent x86 instruction
decoders to recognize such a push+pop sequence as something equally
efficient to the explicit register version?
Btw: One of my hard-copy P4 manuals mentions on the reference page for
the push instruction that a back-to-back push/pop pair that references
memory (rather than a register) will not require the extra cycle that
memory referencing push/pop normally consume. This suggests to me that
the instruction decoder does indeed special case such push/pop pairs,
but it's still a bit vague.
Thanks,
-- Frode Vatvedt Fjeld
- Next message: The Passer-by: "Re: MsDos COM file format"
- Previous message: Gerhard W. Gruber: "Re: kernel"
- Next in thread: Matt Taylor: "Re: x86 stack-frame to stack-frame move"
- Reply: Matt Taylor: "Re: x86 stack-frame to stack-frame move"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|