flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [FULL SUCCESS]assembly time control on struct fields offsets |
Author |
|
ProMiNick 06 Jul 2022, 22:00
I`m glad to inform that state of combining struct mechanism with variable base is changed and finished.
Content of initial topic is replaced with final successfull state. (in initial post struct was defined relative $, but here only test part of rebasing struct that related via register): Code: ... virtual at esp d SYSTEM_INFO end virtual use32 align $10 local@offbase = 0 mov eax,[d.dwPageSize];compiled as mov eax,[d.dwPageSize] where d.dwPageSize=esp+4 align $10 local@offbase = 6 assert d.dwPageSize relativeto esp mov eax,[d.dwPageSize];compiled as mov eax,[d.dwPageSize+6] where d.dwPageSize=esp+4 align $10 local@espIndex = -1 assert d.dwPageSize relativeto $ assert d.dwPageSize relativeto 0 mov eax,[d.dwPageSize];compiled as mov eax,[d.dwPageSize-esp+6] where d.dwPageSize=esp+4 align $10 local@ebpIndex = 4 mov eax,[d.dwPageSize];compiled as mov eax,[d.dwPageSize-esp+ebp*4+6] where d.dwPageSize=esp+4 align $10 local@espIndex = 0 local@offbase = local@offbase+$50 assert d.dwPageSize relativeto ebp*4+esp mov eax,[d.dwPageSize];compiled as mov eax,[d.dwPageSize+ebp*4+$56] where d.dwPageSize=esp+4 align $10 db 0 |
|||
06 Jul 2022, 22:00 |
|
revolution 07 Jul 2022, 04:08
Congrats.
Where can this be used? |
|||
07 Jul 2022, 04:08 |
|
ProMiNick 07 Jul 2022, 05:45
mainly for win32:
Code: ShellExtInit@AddRef: procedure(Self) sub [Self], current_COMobject.SEI ; we cant create ebp frame here it will break logic ShellPropSheetExt@AddRef: ;procedure(Self) mov eax, [Self] ; just a luck that continuing esp frame here is shorter 1 byte due to only 1 use of args or locals add eax, current_COMobject.RefCount invoke InterlockedIncrement, eax ret endp ShellExtInit@Release: procedure(Self) sub [Self], current_COMobject.SEI ; again we cant create ebp frame here it will break logic ShellPropSheetExt@Release: procedure(Self) mov eax, [Self] ; just a luck that continuing esp frame here is same as ebp frame due to only 2 uses of args or locals add eax, current_COMobject.RefCount invoke InterlockedDecrement, eax test eax, eax jnz .locret push ebx mov eax, [Self] push eax push [eax+current_COMobject.lpFileName] call PDClassFactory@CreateInstance.free call PDClassFactory@CreateInstance.free pop ebx invoke InterlockedDecrement, ServerLockCount .locret: ret endp ; here combining together with "sub [Self], current_COMobject.SEI" economy for us ; mov eax, [Self] ; sub eax, current_COMobject.SEI ; invoke ShellPropSheetExt@AddRef,eax ; ret ; and economy ; mov eax, [Self] ; sub eax, current_COMobject.SEI ; invoke ShellPropSheetExt@Release,eax ; ret it was just 1 example. we could use procedure chunks (use parts of procs for another procs) and we not limited to use chunks without ebp only or with ebp only, we could combine them together & increase code readability in own trickery form. yes for good realization of chunks we will needed modification of proc macroset but it mostly trivial after gaining ability of controling struct field members offsets. And my fasmpack project at current state partialy unworked (because sintax used features that was not realized) - it is bad to be package targeted to newbies and contain bugs inside. I plan to reuse this feature in kolibri, wince & in linux examples (and I still don`t added GUI linux ones because of switching my attention to rebase structures on fly) |
|||
07 Jul 2022, 05:45 |
|
revolution 07 Jul 2022, 05:51
I don't follow.
What is "procedure(Self)"? Where are you using the macros in the first post? |
|||
07 Jul 2022, 05:51 |
|
ProMiNick 07 Jul 2022, 06:56
nature of procedure is labeled code.
so for cases when we don`t suppose variant where procedure budy could be skipped we use form: Code: procname: procedure() ; looks same as just "procname:" with comment that this is procedure Code: procname: procedure(args) ; we could define args relative to esp or/and ebp Code: procname procedure(args) ; : - skipped, now procedure is struc not macro, args defined same what macro/struc procedure itself? Code: macro procedure definition& { match (args),definition \{ proc@parameters args \} match (),definition \{ proc@parameters \} } struc procedure definition& { close@@ equ end if ; later used as match first rest,close@@ { close@@ }, in undefined state nothing for rest. than release close@@ if used . .: procedure definition } "macro proc@parameters statement" is mostly clone of classical "macro define@proc name,statement" that is was syntax I used but not realized completely (as thou guess there is esp frame based and it required struct rebasing, because every change of esp affect whole locals & args offsets) Quote: Where are you using the macros in the first post? I will share everything when I finish. |
|||
07 Jul 2022, 06:56 |
|
revolution 07 Jul 2022, 07:12
Okay. I am keen to see how these macros make things easier.
But brackets and colons are harder to type than commas. Code: proc name,arg1,arg2 ; easier to type |
|||
07 Jul 2022, 07:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.