flat assembler
Message board for the users of flat assembler.

Index > Main > passing structure address to procedure

Author
Thread Post new topic Reply to topic
xray



Joined: 22 Jul 2007
Posts: 2
Location: florida
xray
can any one help me? i need to pass a pointer of a structure to a procedure.
and then access certain data from the structure.

for example:

struct TDk
a db 1
b db 2
ends

tdk TDK

stdcall somefunc tdk

proc somefunc lpStrucutre
mov eax,[lpStructure].b ;should be the same as mov eax,[tdk.b]
ret
endp
Post 22 Jul 2007, 17:22
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Code:

;declaration
struct TDk 
a db 1 
b db 2 
ends


;passing:
push tdk
call somefunc

;accessing:
proc somefunc lpStruc
 mov ecx, [lpStruc] ;ecx = address of structure in memory
 mov eax, [ecx + TDK.a] ;eax = member a of structure at address ecx
 ret
endp     
Post 22 Jul 2007, 17:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
xray



Joined: 22 Jul 2007
Posts: 2
Location: florida
xray
thank you very much. just what i needed.
Post 23 Jul 2007, 13:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.