flat assembler
Message board for the users of flat assembler.
Index
> Windows > proc, disable frame setup? Goto page 1, 2 Next |
Author |
|
LocoDelAssembly 13 Feb 2010, 05:28
Quote: FASM uses ESP relative addressing anyway. Not sure what you mean, but proc macro defines the arguments and locals as EBP-based, so that sequence you mention has to be there. The only way to avoid it is by not defining any argument nor locals. The macro could probably be extended to check if any of the EBP-based things are actually referenced and if none of them are then don't generate the prolog (but still generate the appropriate N in "retn N"). |
|||
13 Feb 2010, 05:28 |
|
baldr 13 Feb 2010, 06:09
mindcooler,
There is prologue@proc symbolic constant, it holds the name of macro prologue@proc procname,flag,parmbytes,localbytes,reglist to be expanded at the very beginning of proc. If all else fails, read the source. |
|||
13 Feb 2010, 06:09 |
|
revolution 13 Feb 2010, 06:29
|
|||
13 Feb 2010, 06:29 |
|
baldr 13 Feb 2010, 08:19
revolution,
Regarding the links, esp is quite uninforming. frameless or FPO, perhaps? |
|||
13 Feb 2010, 08:19 |
|
revolution 13 Feb 2010, 10:19
FPO?
And 'frameless' seems like too much to type. I am lazy to type too much. |
|||
13 Feb 2010, 10:19 |
|
mindcooler 13 Feb 2010, 14:32
LocoDelAssembly wrote:
Well, my FASM generates ESP relative code for my arguments: Code: FF75 14 PUSH DWORD PTR SS:[ARG.4] FF75 10 PUSH DWORD PTR SS:[ARG.3] FF75 0C PUSH DWORD PTR SS:[ARG.2] FF75 08 PUSH DWORD PTR SS:[ARG.1] FF15 A2204000 CALL DWORD PTR DS:[<&USER32.DefWindowProcW>] _________________ This is a block of text that can be added to posts you make. |
|||
13 Feb 2010, 14:32 |
|
mindcooler 13 Feb 2010, 14:40
baldr wrote: mindcooler, Yes, I checked the macro include files, but I don't quite understand all the proc macros. The Code: macro prologuedef procname,flag,parmbytes,localbytes,reglist seems to deal with ebp, but I don't see why. Code: { local loc loc = (localbytes+3) and (not 3) parmbase@proc equ ebp+8 localbase@proc equ ebp-loc if parmbytes | localbytes push ebp mov ebp,esp if localbytes sub esp,loc end if end if irps reg, reglist \{ push reg \} } _________________ This is a block of text that can be added to posts you make. |
|||
13 Feb 2010, 14:40 |
|
revolution 13 Feb 2010, 14:47
mindcooler wrote: Well, my FASM generates ESP relative code for my arguments: |
|||
13 Feb 2010, 14:47 |
|
mindcooler 13 Feb 2010, 16:58
I'm using
Code: include 'win32wxp.inc' _________________ This is a block of text that can be added to posts you make. |
|||
13 Feb 2010, 16:58 |
|
LocoDelAssembly 13 Feb 2010, 17:03
Where do you see ESP there???
This is what OllyDbg decodes for one of those pushes opcodes: Code: FF75 08 PUSH DWORD PTR SS:[EBP+8] All start with FF75, so in not even a single case there was an ESP-based reference. |
|||
13 Feb 2010, 17:03 |
|
mindcooler 13 Feb 2010, 23:00
Sorry, I seem to have assumed that ARG.1 was relative to ESP. In light of this it seems the question is; how do you do ESP addressed arguments? I don't think I'll ever need EBP-based parameters, and I want EBP unused so I can use EBP for short data addressing. If I can't use the existing proc macro, is there any others I can use for subroutines, or am I supposed to do them manually?
_________________ This is a block of text that can be added to posts you make. |
|||
13 Feb 2010, 23:00 |
|
revolution 14 Feb 2010, 00:31
mindcooler wrote: In light of this it seems the question is; how do you do ESP addressed arguments? http://board.flatassembler.net/topic.php?t=5938 is one way to do it. There are other ways also that may be more convenient for you. But do take the time to read the entire fist post to realise both the advantages and disadvantages. It is not all easy going with ESP as a base pointer, so consider carefully whether you want to completely eliminate EBP based variables. I previously said: wrote: For those of you that may not be aware of why ESP basing is not normally used, here are some reasons why you might not use it: |
|||
14 Feb 2010, 00:31 |
|
mindcooler 15 Feb 2010, 01:05
Hmm, my experiences thus far, correct me if I'm wrong:
- Without EBP addressing you can't invoke from the stack, as ESP changes at runtime. Unless you start calculating offsets manually that is. - EBP addressing is one byte shorter than ESP addressing I think I'm going to free up another register from my data addressing :S Can you do without ESI or EDI? :P _________________ This is a block of text that can be added to posts you make. |
|||
15 Feb 2010, 01:05 |
|
mindcooler 15 Feb 2010, 02:09
Is this the way to do subroutines if you do away with proc?
Code: WindowProc: virtual at esp+8 .wmsg rd 1 end virtual cmp [.wmsg],WM_DESTROY jne .exit invoke PostQuitMessage,0 .exit: jmp [DefWindowProc] _________________ This is a block of text that can be added to posts you make. |
|||
15 Feb 2010, 02:09 |
|
revolution 15 Feb 2010, 06:55
mindcooler wrote: Is this the way to do subroutines if you do away with proc? |
|||
15 Feb 2010, 06:55 |
|
Tomasz Grysztar 15 Feb 2010, 07:32
Since DefWindowProc is a kind of WindowProc, it has the exactly same parameters by definition. Actually it's a nice interface forwarding you have here.
|
|||
15 Feb 2010, 07:32 |
|
mindcooler 15 Feb 2010, 12:35
revolution wrote: Extremely hacky way to do things. I call it "not doing unnecessary stuff". This is the main reason for my switch from high level languages. I chose fasm because I hate linkers :P Tomasz Grysztar wrote: Actually it's a nice interface forwarding you have here. Coming from you, that means a lot to me :) I now have this basis for a WindowProc: Code: WindowProc: virtual at esp+8 .wmsg rd 1 end virtual cmp [.wmsg],WM_DESTROY jne .default invoke PostQuitMessage,0 .exit: xor eax,eax ret $10 .default: jmp [DefWindowProc] .end start We'll see if I get into addressing trouble as I expand on it. being able to use EBP for work data not on the stack will surely save addressing bytes? _________________ This is a block of text that can be added to posts you make. |
|||
15 Feb 2010, 12:35 |
|
baldr 15 Feb 2010, 16:45
revolution wrote: Extremely hacky way to do things. That's why I do hate the way MS extends [for example] MessageBox into MessageBoxEx and later into [undocumented] MessageBoxTimeout (i.e. appending new parameter at the end instead of inserting it as first). pop eax / push default_value / push eax / jmp functionEx looks much better than copying entire call frame. FPO is "frame pointer omission", by the way. __________ mindcooler, You have to save ebp anyway to be compliant to stdcall / cdecl, haven't you? And each access through esp adds SIB byte to the toll… where is the profit? As far as I can see, only elimination of prologue (3 bytes)/epilogue (1 byte) matters, so (byte-wise) four esp-relative accesses is the break-point. |
|||
15 Feb 2010, 16:45 |
|
revolution 15 Feb 2010, 17:15
baldr: The potential "profit" is the extra register for general purpose computations.
|
|||
15 Feb 2010, 17:15 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.