Re: Is it catachrestial as 'Effective Addresses' in NASM documentation?
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Sun, 30 Apr 2006 12:57:40 -0400
Julienne Walker wrote:
Frank Kotler wrote:
Julienne Walker wrote:
...
one can easily see why lea exists:
mov ebx,mem
mov esi,2
; Simulate "lea edx[ebx+esi*4]"
mov edx,ebx
imul esi,4
add edx,esi
Stop right there! That's "lea".
mov eax,[edx] ; eax = 3
This is *not* part of what "lea" does. The confusing thing about "lea"
is that it *looks* like a memory instruction, but it's an arithmetic
instruction - just does the calculation, doesn't touch memory at all.
Sorry, the memory access wasn't meant to be a part of the lea
simulation at all. It just happened to be the next instruction since
all of the examples ended up accessing the effective address.
Consistency and whatnot. Would this work better?
; Simulate "lea edx[ebx+esi*4]"
mov edx,ebx
imul esi,4
add edx,esi
; Access the result
mov eax,[edx] ; eax = 3
Exactly. As you say in a previous post, "lea" is the odd one.
I guess Pipi's point is that "ebx + esi * 4" is the "effective address (expression)", but that with the brackets, "[ebx + esi * 4]", it refers to contents of memory. It's true that the manual doesn't make this distinction clear.
I'm not sure the distinction is important... an "address" is "just a number" unless we *use* it as an address... so "mem" is "just a number" which happens to be an address... "[mem]" is "contents of memory", but it's the brackets that make "mem" an address and not just number... does that make any sense at all???
Best,
Frank
.
- References:
- Is it catachrestial as 'Effective Addresses' in NASM documentation?
- From: pzgyuanf
- Re: Is it catachrestial as 'Effective Addresses' in NASM documentation?
- From: Julienne Walker
- Re: Is it catachrestial as 'Effective Addresses' in NASM documentation?
- From: Frank Kotler
- Re: Is it catachrestial as 'Effective Addresses' in NASM documentation?
- From: Julienne Walker
- Is it catachrestial as 'Effective Addresses' in NASM documentation?
- Prev by Date: Re: I'd like to learn asm...
- Next by Date: Re: I'd like to learn asm...
- Previous by thread: Re: Is it catachrestial as 'Effective Addresses' in NASM documentation?
- Next by thread: frame pointer
- Index(es):
Relevant Pages
|