News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

addressing array elements ...

Started by James Ladd, March 06, 2005, 12:21:17 AM

Previous topic - Next topic

James Ladd

I have the following:

    local events:WSANETWORKEVENTS
    local watch[2]:WSAEVENT

What I need to do is set handle1 into watch[0] and handle2 into watch[1] but the
correct way to do it eascapes me right now.
Can someone help please?
Rgs, striker

sluggy

Something like this:


   assume esi : ptr WSANETWORKEVENTS
   lea esi, <your array name>                  ;point to the first struct in the array
   mov eax, <your event>
   mov esi.lNetworkEvents, eax

   add esi, sizeof WSANETWORKEVENTS   ;point to the second struct in the array
   mov eax, <your event>
   mov esi.lNetworkEvents, eax

   assume esi : nothing


Of course this can be made to look a lot prettier in your real code  :P

James Ladd

Sluggy,
Thanks. Its not exactly what i wanted but it did answer my question.
This is what I have now

    local watch[2]:WSAEVENT
    :
    lea esi, watch
    mov esi, handle1
    add esi, sizeof WSAEVENT
    mov esi, handle2

Ta.
Rgs, striker

donkey

Hi,

Shouldn't it be...

    local watch[2]:WSAEVENT
    :
    lea esi, watch
    mov [esi], handle1
    add esi, sizeof WSAEVENT
    mov [esi], handle2


You would have to dereference the address contained in ESI in order to mov the data into the right memory buffer.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

James Ladd

#4
Donkey,
When you say "Shouldnt it be" then most likely it should be.
Ill change what I have to what you suggest coz what I have dont work. :(
Thanks Donkey.

ps - im always getting [reg] and reg confused.

donkey

Hi Striker,

MASM adds the braces in some cases and not in others, that is what we mean in the GoAsm community when we say the syntax is ambiguous. In GoAsm which is much more explicit you would be required to enclose all memory based labels in braces so you get used to it much faster. This isn't to say that there is anything wrong with the way MASM does it, simply that the lack of braces on memory labels but requiring them for registers is an ambiguous situation. When I program in MASM I usually add the braces anyway, it helps me to differentiate between constants, direct to reg and memory based operations.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

James Ladd

Donkey,
I started with goASM and I love it, however, for my current project its MASM as I want to give something to that community.
I dont think the work will be as accepted if it were for goASM.
Rgs, Striker.

Rifleman

Donkey,
If I ever move to GoASM, and it looks like I am going to, it will be because of that one very frustrating point.  After all this time, you would think that MASM would have been rewritten to solve this silly ambiguity!  Sorry to interrupt, you just struck a chord, as it were.

Paul