News:

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

Problems with creating a Struct in MASM32.

Started by Shooter, February 15, 2011, 09:08:59 PM

Previous topic - Next topic

Shooter

Hey guys,
I'm getting this error:
QuoteReadRegKey.asm(324) : error A2070: invalid instruction operands

For this line:
mov IPIndexNum,[edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwIndex

I'm trying to implement Michael's example from his sample, GetIpAddrTable, from his original line:
Quote        printf "\n\tInterface Index[%d]:\t%d\n", \
                esi,[edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwIndex

I've tried to define IPIndexNum as both "DD ?" and "DW ?". The goal is to create a GUI application from his example, so I'd like to store the values into a variable to be called on by SendDlgItemMessage later on.

Can anyone give me a clue how to do this in MASM32?

Thanks,
-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

fearless

I would move it to a register first, then move that to your variable (assuming IPIndexNum is defined as a dword value), so:

mov eax, [edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwIndex
mov IPIndexNum, eax
ƒearless

dedndave

or...
        push    [edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwIndex
        pop     IPIndexNum

might be a byte or 2 smaller   :P

fearless

ƒearless

dedndave

when using register-index addressing - there may be no advantage to push/pop
i dunno - i'd have to disassemble some code to see

Shooter

You guys are my heroes! I did that push/pop thing and it works great. Now.... moving on to translating the rest of it into something I want it to do via my GUI. He-he-hehhh.  :bdg
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

oex

FYI there is a masm32 macro

m2m which will make your code a little neater in this context:

m2m IPIndexNum, [edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwAddr

Alternatively there is an equivilent eax register version mrm
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

MichaelW

In my GetIpAddrTable code, after I posted I noticed that my indirect memory operands are "over-specified". So for example in the code below, while the MIB_IPADDRTABLE reference is necessary to indicate what [edi] is pointing to, the MIB_IPADDRROW reference is not because the table member is declared in the MIB_IPADDRTABLE structure as a MIB_IPADDRROW structure.


        push [edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwAddr
        pop  IPAddr.S_un.S_addr


And the code can be shortened to:


        push [edi].MIB_IPADDRTABLE.table.dwAddr
        pop  IPAddr.S_un.S_addr

eschew obfuscation

Shooter

Quote from: MichaelW on February 26, 2011, 09:28:41 PM
In my GetIpAddrTable code, after I posted I noticed that my indirect memory operands are "over-specified".

Sometimes for a person like me, being "over-specified" can have it's advantages... that told me how it 'really' worked.  :bg
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.