flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > Define proc inside a struct

Author
Thread Post new topic Reply to topic
M_H



Joined: 25 Feb 2017
Posts: 2
Define proc inside a struct
Hi eveyone
im new to asm language
i was woundering how can i define someting like a proc inside a struct

i use this code to define a struct but i need to pass some parameters to the print function

struct String DATA
jmp .x
.len dw .strend-.str
.str db DATA,' '
.strend db 0
.Print:
invoke MessageBox,HWND_DESKTOP,.str,"",MB_OK
ret
.x:
ends

_________________
Lets Learn Assembly
Post 25 Feb 2017, 19:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14671
Location: Origae-6
If you want to pass parameters to .Print then you can do it just as normal. Assuming you are using stdcall then:

Code:
struct String DATA
        jmp .x
        .len dw .strend-.str
        .str db DATA,' '
        .strend db 0
        .Print:
        ;access first parameter at [esp+8]
        invoke MessageBox,HWND_DESKTOP,.str,[esp+8],MB_OK
        ret
        .x:
ends
my_string String 'Title'
stdcall my_string.Print,'Text'  ;pass 'Text' as a parameter

Post 26 Feb 2017, 00:11
View user's profile Send private message Visit poster's website Reply with quote
M_H



Joined: 25 Feb 2017
Posts: 2

revolution wrote:
If you want to pass parameters to .Print then you can do it just as normal. Assuming you are using stdcall then:

Code:
struct String DATA
        jmp .x
        .len dw .strend-.str
        .str db DATA,' '
        .strend db 0
        .Print:
        ;access first parameter at [esp+8]
        invoke MessageBox,HWND_DESKTOP,.str,[esp+8],MB_OK
        ret
        .x:
ends
my_string String 'Title'
stdcall my_string.Print,'Text'  ;pass 'Text' as a parameter




i don't think its that easy
Im keeping recieving this error:
Operand size not specifing
push [ebp+8]
Image

_________________
Lets Learn Assembly
Post 26 Feb 2017, 12:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14671
Location: Origae-6
Okay I forgot the dword override.

Code:
        invoke MessageBox,HWND_DESKTOP,.str,dword[esp+8],MB_OK

Post 26 Feb 2017, 12:54
View user's profile Send private message Visit poster's website 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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.