Sorry to ask such a basic question, but I haven't really come across this before and I didn't see an explaination for it in the tutorials I have and what not. So anyway, could someone explain this syntax to me please?....

mov , ebx

... I just don't understand what the [] mean. I also don't see how the eax register has a member (is that even what it is? I'm just guessing.) Thanks.
Posted on 2001-10-01 05:36:31 by AlexEiffel
>I just don't understand what the [] mean. I



value dd 1
...
mov eax, value ; eax == 1
...
mov ecx, eax ; ecx == 1 (value of eax)
mov ecx, [eax] ; ecx == address of eax
...


another example:



...
assume eax:ptr NMHDR ; eax is pointer to structure

.if [eax].idFrom == ID_LISTVIEW ; get structure member
...


HTH,
bAZiK
Posted on 2001-10-01 05:49:57 by bazik
hi,
first of all the explanation of the member of eax. i'm sure that some lines above in your code there is something like:

assume eax:bri_structure ;whatever this structure is

so eax can be handled like a viariable that has the type of the bri_structure. that eases accessing the elements that are in eax. and obviously eax is a pointer to such a structure of numbers, and you want to move the data into memory, and you don't want to replace the value in eax. therefore you need the []

summary: eax can become a structure by assuming eax with such a thing, but don't forget to assume eax:nothing after you've finished your operation.
[] are used to store a value where the pointer points to. let's say eax points to 4356678, so this value is in eax now. but you don't want to replace this value, but the value that eax points to.

hmmm, perhaps someone else can explain that better. :tongue:

NOP-erator
Posted on 2001-10-01 05:53:52 by NOP-erator
Alex,

The square brackets [] are a basic notation in Intel assembler that mean "dereferencing" an address. To explain, a variable in memory has an address and a value. Its address is a zero based offset and in 32 bit windows it is a DWORD in size.

If you know the ADDRESS of the variable, you "dereference" it to get the value. If you have the address of a variable in EAX, the notation to get its VALUE is simple,

MOV EAX, Memory_Value
MOV EAX,

You now have the VALUE at that ADDRESS in EAX.

================
mov , ebx
================

This is a structure member of some type, probably the ASSUME directive has been used to make EAX represent a structure. What it is doing is loading one member of a structure with the VALUE in EBX. The use of the square brackets is corect in that it indicates a MEMORY operand which the structure is.

Regards,

hutch@pbq.com.au
Posted on 2001-10-01 07:01:01 by hutch--
I think, Alex references to the article "Folder Help", so I have to
explain a liitle more ...

Since I'm using WATCOM assembler, I must give all structures
an unique prefix, so that the assembler can differ between equal
named entries in different strucs. Otherwise I would have to use
a "longly" syntax like [(struct BROWSEINFO) eax.hwndOwner]

Normally I'm using three start-letters of the struct, in this case:


BROWSEINFOA struc
bri_hwndOwner dd ?
bri_pidlRoot dd ?
bri_lpszDisplay dd ?
bri_lpszTitle dd ?
bri_ulFlags dd ?
bri_lpfn dd ?
bri_lParam dd ?
bri_iImage dd ?
BROWSEINFOA ends


The syntax in MASM is explained by the other repliers of this thread.
Posted on 2001-10-01 07:30:02 by beaster
Thanks guys. I did get that line of code from the folder thread, but it was just because that was the first place I found the syntax when I decided to ask about it. What made me ask about it was a reply to my question about using directx and asm that had a code piece like that.
Posted on 2001-10-01 15:34:38 by AlexEiffel