flat assembler
Message board for the users of flat assembler.

Index > Main > proc getPos, lParam, thisPos:RECT

Author
Thread Post new topic Reply to topic
procyon



Joined: 07 Sep 2007
Posts: 12
procyon 14 Jun 2011, 10:09
Hi,

Code:
proc getPos, lParam, thisPos:RECT    


isn't accepted by compliler, so I'm wondering how I can pass a RECT structure to a proc so that I can access
Code:
[thisPos.left]    
etc in the proc.

btw, I know there are workarounds, I'm using
Code:
proc getPos, lParam, buff     ; buff is a RECT struct
                                         ; but I don't know how to pass it.
        pushad
        mov     eax, [lParam]
        mov     ebx, eax
        and     eax, 0xFFFF
        shr     ebx, 16
        mov     edi, [buff]
        mov     [edi], eax
        mov     [edi+04], ebx
        popad
        ret
endp
    


at the minute. Just want to know if there is something I'm missing about passing STRUCTS to a PROC so that I can access the 'proper' offsets (i.e. .left .top etc)

thx

pro


Last edited by procyon on 14 Jun 2011, 10:51; edited 2 times in total
Post 14 Jun 2011, 10:09
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 10:46
Code:

mov eax,RECT
stdcall getPos,x,x,eax

proc getPos, lParam, thisPos:dword

mov ebx,[thisPos]
mov ecx,[ebx]

endp
    


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 14 Jun 2011, 10:46
View user's profile Send private message Send e-mail Reply with quote
procyon



Joined: 07 Sep 2007
Posts: 12
procyon 14 Jun 2011, 10:49
Is that a typo ouadji?

You're passing 3 params to a 2 param proc
Post 14 Jun 2011, 10:49
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 10:56

yes, typo, sorry !
BSOD for me ! Wink
Code:
stdcall getPos,x,eax    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 14 Jun 2011, 10:56
View user's profile Send private message Send e-mail Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 14 Jun 2011, 18:50
Actually you dont need to put into eax first, just pass its offset.
In high level languages like C, there are internals to handle passing
structures to a procedure as opposed to passing a pointer to the structure.
With ASM we pass a pointer to the structure as ouadji has demonstrated.
Post 14 Jun 2011, 18:50
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 14 Jun 2011, 18:51
My fASM is a bit rusty but wouldn't this work...

------- text below may be completely untrue ------

Code:
proc getPos, lParam, thisPos
        pushad
        mov     eax, [lParam]
        mov     ebx, eax
        and     eax, 0xFFFF
        shr     ebx, 16
        mov     edi, [thisPos]
        mov     [edi + RECT.left], eax
        mov     [edi + RECT.top], ebx
        popad
        ret
endp 
    


What would [thisPos.left] translate to?
thisPos is EQU to EBP+8
so you have to MOV edi, [EBP+8] ; MOV edi, [thisPos] to get the address to your RECT.
From there you can do a ? virtual at edi / RECT / end virtual ? may that would let you reference [edi .left]
Post 14 Jun 2011, 18:51
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 19:04

.... as ouadji has demonstrated.

thank you bitshifter for the green color Razz

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 14 Jun 2011, 19:04
View user's profile Send private message Send e-mail Reply with quote
procyon



Joined: 07 Sep 2007
Posts: 12
procyon 14 Jun 2011, 19:10
hi bitshifter, the RECT struct is being passed in [thisPos], not [lparam]. I move [lparam] into eax to manipulate it then move the results into [thisPos].

Hi r22, long time no speak Very Happy

It appears your fasm isn't as rusty as mine, lol. I knew there was a way to reference the RECT 'correctly', just couldn't get my head around it Embarassed

Many thanks

pro
Post 14 Jun 2011, 19:10
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 14 Jun 2011, 21:53
I understand you, but what i meant was to pass thisPos -- not [thisPos]

thisPos == offset of structure
[thisPos] == first member of structure (RECT.left)
Post 14 Jun 2011, 21:53
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.