flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
hopcode 22 Aug 2008, 10:29
Hallo all,
<reedited> /an old select/case macro Example of use: ... read new post Last edited by hopcode on 01 Sep 2008, 04:56; edited 1 time in total |
|||
![]() |
|
vid 22 Aug 2008, 14:33
Using macro for "break" or "continue" in assembly is somewhat retarded... "break" and "continue" are HLL substition for most-often used cases of "goto"/"jmp".
Same for doing "case" without jump table in assembly. "case" command is exactly the best example where HLL code has advantage over Asm code - compiler can analyze list of options, and generate ideal code for it (combination of conditional jumps and binary search(es)). There are even specialized tools like "flex", which do nothing else but this. If course you *can* do it in asm, but in practice your code would become unreadable, unmaintainable, etc... so no one really does it. |
|||
![]() |
|
hopcode 23 Aug 2008, 01:27
vid wrote: Using macro for "break" or "continue" in assembly is somewhat retarded... "break" and "continue" are HLL substition for most-often used cases of "goto"/"jmp".Same for doing "case" without jump table in assembly. ... Thank you vid for your note. I agree totally with you: "break","continue","select","case" are all for HLL. Personally, i dont like them. They can be avoided with no difficulty by coding them manually to get the best code in a short time: ... mov eax,[wmsg] cmp eax,WM_CLEAR jz codeforWM_CLEAR cmp eax,WM_COMMAND jz codeforWM_COMMAND ... But i find the real problem with fasm 1.67 in the building up of the jump table: 1- jump table (or comparison table) 2- code to execute (always forwarded) Anyway, if i do not err, a switch-case system is already a high level abstraction, it is to say, an abstract construct in relation to the way of assembler coding. In this case other compilers or preprocessor could do their work with their optimization. For this reason i dont like this construct: it is too much "high", too much "interpreted" and interpretable, too much abstract. I have tried different solutions to build up a jump table. None of them satisfies completely me. In conclusion, what i aimed to was avoiding writing always the same code, particularly for windowprocs. I will put examples later in my Winmacro thread... ... hopcode |
|||
![]() |
|
hopcode 23 Aug 2008, 01:31
revolution wrote: keep in mind that break is already a keyword, so you are overriding it's normal function. Thank you,revolution, i have totally forgotten the break directive. At the moment i dont know how to use a "break" instruction macro that avoids interference with the break directive. I have found an opportunity in the use of a "continue" instruction instead of "break" (as a matter of fact i have used the "break" instruction as a way to jump to the default block). I find it useful extending the "continue" instruction as shown in the following example of use : ..little improvements..24.08.2008 but i am not at all convinced ![]() ... Last edited by hopcode on 01 Sep 2008, 04:57; edited 1 time in total |
|||
![]() |
|
hopcode 01 Sep 2008, 04:48
Hallo all,
here my definitive solution for a select/case with a comparison table... version updated [Sonntag] - 07.Juni.2009 now it allows things like: |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.