flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Surprises of stdcall |
Author |
|
revolution 15 Feb 2010, 10:12
It has been mentioned before. IIRC, I even suggested a method (and gave the macros) to fix it but no one thought it needed fixing. But if not fixed it should be mentioned in the macro documentation.
|
|||
15 Feb 2010, 10:12 |
|
Picnic 15 Feb 2010, 11:01
revolution wrote: It has been mentioned before. |
|||
15 Feb 2010, 11:01 |
|
revolution 15 Feb 2010, 13:18
|
|||
15 Feb 2010, 13:18 |
|
booter 01 Mar 2010, 06:56
revolution wrote: It has been mentioned before. IIRC, I even suggested a method (and gave the macros) to fix it but no one thought it needed fixing. But if not fixed it should be mentioned in the macro documentation. A year passed since http://board.flatassembler.net/topic.php?t=8319, but the problem is still here. It's definitely not right to have FASM users to remember about this. I would say, it's extremely frustrating to deal with this "errata". As a simple solution I propose just detect this problem in macros and raise an error to notify FASM user and allow him to change his code instead of spending hours looking for a bug in the program. Tomasz, what do you think about this? revolution, can you please write a macro to detect this? BTW, it may be even better solution because user can re-arrange his code and avoid inefficiensy and complexity related to your "automated" solution (I'm not critisizing your solution, just suggesting an alternative, please don't consider it offensive in any way). |
|||
01 Mar 2010, 06:56 |
|
revolution 01 Mar 2010, 08:31
booter wrote: A year passed since ... booter wrote: revolution, can you please write a macro to detect this? BTW, it may be even better solution because user can re-arrange his code and avoid inefficiensy and complexity related to your "automated" solution ... Code: macro callpusher ret_arg_count,[arg] { common local edx_corrupted_flag, edx_save_flag, temp_edx_save_flag, arg_count, temp_arg_count, ip, opcode temp_arg_count=0 reverse match x =edx y,:arg: \{ if defined edx_corrupted_flag & edx_corrupted_flag=1 temp_edx_save_flag=1 edx_corrupted_flag=0 rb -1 ;error with use of edx! end if \} ip=$ pushd arg load opcode from ip if opcode=0x8d edx_corrupted_flag=1 end if temp_arg_count=temp_arg_count+1 common if defined temp_edx_save_flag edx_save_flag=1 end if arg_count=temp_arg_count ret_arg_count=arg_count } |
|||
01 Mar 2010, 08:31 |
|
baldr 02 Mar 2010, 00:05
revolution,
What about two-pass approach? First pass pushes everything besides addr args (push any for them), then second pass use lea/mov [esp+X] to put EAs in their places (only for addrs, granted we have macro-expansion-time calculations). No need to bother with which register is corrupted. The only problem is that addr is a part of pushd macro semantics, not stdcall/ccall/invoke/cinvoke. |
|||
02 Mar 2010, 00:05 |
|
revolution 02 Mar 2010, 00:17
baldr wrote: revolution, Code: stdcall function, addr edx+8, addr ecx+8, addr edx+4, addr ecx+4 |
|||
02 Mar 2010, 00:17 |
|
baldr 02 Mar 2010, 00:27
revolution,
Nobody's perfect. Indeed, many addrs are evil and should be banned to Void forever. Yet push/lea/xchg trick owns them all (though slowly). |
|||
02 Mar 2010, 00:27 |
|
revolution 02 Mar 2010, 00:29
I can be solved without xchg. I don't use xchg in my macros.
|
|||
02 Mar 2010, 00:29 |
|
baldr 02 Mar 2010, 00:36
revolution,
I know that it can be. fasm macro and interpretive facilities are powerful enough for that. I'll look into that, definitely. |
|||
02 Mar 2010, 00:36 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.