Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   someone help out this newbie (http://www.programmingforums.org/showthread.php?t=11052)

rsnd Aug 12th, 2006 9:37 PM

someone help out this newbie
 
What is this?
:

lea    ecx, ds:80h[ecx*4]

is it simply ecx = ecx * 4? Does it have anything to do with the data segment?

it appears here:
:

this::0 = &some_vector_table;
this::8 = 0;

if (unknown_global_1000EA80 == 0 || unknown_global_1000EA84 & 31==0) {
        mov    ecx, unknown_global_1000EA84
        lea    ecx, ds:80h[ecx*4]

        unknown_global_1000EA80 = realloc(unknown_global_1000EA80, ecx);
}

unknown_global_1000EA80[unknown_global_1000EA84] = &this;
unknown_global_1000EA84++;
this::12 = 0;
if (someglobalsocketvariable == 0) {
        some_fdset.fd_count = 0;
        other_fd.fd_count = 0;
}

thanks

Harakim Aug 13th, 2006 3:35 AM

I haven't programmed in x86 assembly for years.

lea is load effective address

lea ecx, ds:80h[ecx*4]

This loads an address into ecx. It doesn't actually load anything from memory. It just calculates the address. I think it basically allows you to use mathmatical operations rather than instructions to make code cleaner.

ds is one of the segmentation registers. It seems like I used ds to access the hard drive. Since you have the word socket in there, it makes me think it could be the network, although I'm speculating now.

Hopefully I helped a little.

DaWei Aug 13th, 2006 12:07 PM

Using lea is like setting a pointer to point to a variable, rather than fetching the variable. DS is the data segment register. It is not required that one use if strictly for that, more in the nature of a convention.

rsnd Aug 14th, 2006 2:09 AM

hmm... I dont understand that data segment register bit: "ds:80h." There are a couple of strings declared on 80h offset of data segment and should not be relevent. What is its purpose there? From what I see its calculating the new size of a buffer. From what I remember, my college professor used to use "rAB:rCD:rEF" notation to denote higher resolution numbers.


All times are GMT -5. The time now is 6:14 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC