flat assembler
Message board for the users of flat assembler.
Index
> Main > Structure & procedures |
Author |
|
JohnFound 09 Feb 2004, 19:03
If you are talking about local variables:
Code: struc SS { .val1 rd 4 .val2 dd ? } proc PP, arg1, arg1, arg3 ; declare local variables here with "." in the begining: .local1 SS .local2 dd ? enter mov eax,[.local1.val1+4*2] sub eax, [.local1.val2] add eax, [.local2] return |
|||
09 Feb 2004, 19:03 |
|
n0p 09 Feb 2004, 19:19
No, I want to deliver structure in procedure as argument and then to get acces to any element.
Code: proc PP, arg1 enter mov eax,[arg1.val1] return How can i tell to compiler that the arg1 is structure? _________________ English isn't my native, so sorry for any mistakes I can make... |
|||
09 Feb 2004, 19:19 |
|
JohnFound 09 Feb 2004, 19:29
n0p wrote: No, I want to deliver structure in procedure as argument and then to get acces to any element. Actually arg1 can't be structure. stdcall parameter passing convention allows only dwords as arguments. You can pass pointer to your structure instead. Code: proc MyProc1 .rect RECT enter ..... lea eax, [.rect] stdcall MyProc2, eax .... return ; returns: ecx - width, edx - height of rectangle. proc MyProc2, ptrRect enter mov eax, [ptrRect] mov ecx, [eax+RECT.right] mov edx, [eax+RECT.bottom] sub ecx, [eax+RECT.left] sub edx, [eax+RECT.top] return Help this will help Regards |
|||
09 Feb 2004, 19:29 |
|
n0p 09 Feb 2004, 20:13
Thanks a lot! It's realy works and it is what I want!
_________________ English isn't my native, so sorry for any mistakes I can make... |
|||
09 Feb 2004, 20:13 |
|
Dryobates 09 Feb 2004, 22:10
Pushing whole structure on stack isn't good programing style, but if you want that modified macro I think should do this (I don't know is this works ):
Code: macro proc_ext name,[arg, type] ; define procedure { common name: virtual at ebp+8 if ~ arg eq forward arg type common end if ..ret = $ - (ebp+8) end virtual local ..dynamic_data,..dynamic_size dynamic_data equ ..dynamic_data dynamic_size equ ..dynamic_size virtual at ebp - dynamic_size dynamic_data: } struc some_str { .val1 rd 4 .val2 dd ? } proc_ext PP, var, some_str enter mov eax, [var.val1+4*2] return But how to push structure on stack you have to think. |
|||
09 Feb 2004, 22:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.