Re: "TYPEDEF PTR with STRUCT" masm32



On Sat, 14 Oct 2006 01:50:05 -0500, "Ratch" <spamtrap@xxxxxxxxxx>
wrote:

<snip>

Don't define your structure within a .DATA? or .DATA segment.
Actually, AFAIK, it makes no difference where a structure or typedef
is.

I never use TYPEDEFs.
They have thier uses.

I never try to initialize structure items within a STRUCT
statement even though MASM says you can do so.
What's so hard about:
varname myStrc <>
or
varname myStrc <1,2>
?
In any case, the OP wasn't initalizing the structure.

It is easier to use DWORD,
WORD, and BYTE within a .DATA? or .DATA segment to make space for the
structure, and then use the structure as a template.
And hope you remember to change it's size when you change the struct.

Be careful using single or double letter labels for structure items, because a lot of them
are reserved words.
True to some extent.


myStrc STRUCT
ABC DWORD ?
DEF DWORD ?
myStrc ENDS
; lpMyStrc TYPEDEF PTR myStrc

.DATA?
BYTE 10 DUP (?)
yourstruc BYTE myStrc DUP (?)

.CODE

You changed the meaning of the code, my example didn't.

LEA EDX,OFFSET yourstruc
push eax
push ebx
mov eax, [EDX.myStrc.ABC]
mov ebx, [yourstruc.myStrc.DEF]
mov [yourstruc.myStrc.ABC], ebx
mov [yourstruc.myStrc.DEF], eax
pop ebx
pop eax
--
ArarghMail610 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.

.



Relevant Pages