Valhalla Legends Forums Archive | Assembly Language (any cpu) | neg esi

AuthorMessageTime
Camel
[code].text:6F6721BB lea esi, [eax+9]
.text:6F6721BE neg esi
.text:6F6721C0 xor ebx, ebx
.text:6F6721C2 and esi, 3Fh[/code]

If I am not mistaken, the first line should set esi to the offset (eax+9). What, then, is the point of inverting a pointer?
September 17, 2003, 11:07 PM
iago
eax isnt' necessarely a pointer. Using a lea is an optimized way of adding 2 variables and storing them somewhere else.

It's basically, esi = ~(eax + 9);
September 17, 2003, 11:10 PM
Camel
Ah, thanks.

[edit][code].text:6F6721F9 lea esp, [esp+0][/code]
Uh, esp = esp + 0?
September 17, 2003, 11:21 PM
iago
yes, actually.. that load the address of [esp] into esp .. I don't know why it would do that, unless I was horribly mistaken
September 18, 2003, 12:32 AM
Camel
Well, I should say esp = &(*(esp+0));
September 18, 2003, 2:47 AM
Skywing
[quote author=iago link=board=7;threadid=2733;start=0#msg21538 date=1063845177]
yes, actually.. that load the address of [esp] into esp .. I don't know why it would do that, unless I was horribly mistaken
[/quote]
That is a fairly common "large nop" when the compiler has a specific amount of bytes it wants to fill with do-nothing code with as minimal of a performance impact as possible. Typical reasons for this are aligning a code segment that the compiler thinks will be used a good deal.
September 18, 2003, 5:58 AM

Search