flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
MHajduk
JohnFound wrote: Here is a simple pattern match program, similar to the DOS/Linux glob matching. Please, if someone wants, make some tests. Also, suggestions about size optimizations are welcome. ![]() |
|||
![]() |
|
JohnFound
It is FreshLib syntax. The procedure header can be easily edited for whatever macro library you use.
|
|||
![]() |
|
MHajduk
JohnFound wrote: It is FreshLib syntax. The procedure header can be easily edited for whatever macro library you use. ![]() Another question. Why don't use 'lodsb' here: Code: .main_loop2: mov al, [esi] ; from the pattern inc esi |
|||
![]() |
|
JohnFound
MHajduk wrote: Another question. Why don't use 'lodsb' here: It better corresponds with the next instruction pair "mov ah, [edi]". As long as both make the same (load char from the string), I considered they have to look the same. It makes the code more readable. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
MHajduk
Well, to substitute these two instructions:
Code: mov ah, [edi] ; from the string inc edi Code: xchg esi, edi xchg ah, al lodsb xchg ah, al xchg esi, edi ![]() |
|||
![]() |
|
HaHaAnonymous
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 19:10; edited 1 time in total |
|||
![]() |
|
ejamesr
If you're not too concerned about alignment and would prefer to save space, use 'align 1' in front of your procedures. This will save, on average, a couple bytes per procedure.
|
|||
![]() |
|
JohnFound
ejamesr wrote: If you're not too concerned about alignment and would prefer to save space, use 'align 1' in front of your procedures. This will save, on average, a couple bytes per procedure. Well, "align 1" is actually NOP. The assembler always align on 1. The alignment of the procedures in FreshLib is optional, so the user of the library can choose the alignment with "options.AlignCode". _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
ejamesr
'align 1' does nothing; it will not insert a NOP into the code. But if it replaces a larger-sized 'align' statement, it can eliminate NOPs.
My previous comment assumed you used 'align 4' or even 'align 16' for your procedures. If not, please disregard my comment. Since I'm always more interested in speed than size (using assembly pretty much guarantees my code will be smaller than when using a different language), I periodically consult the latest version of the "IntelĀ® 64 and IA-32 Architectures Optimization Reference Manual" (July 2013). On page 3-9: Quote: Assembly/Compiler Coding Rule 12. (M impact, H generality) All branch targets should be 16-byte aligned. Quote: Alignment of code can be an issue for the Pentium M, Intel Core Duo and Intel Core 2 Duo processors. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.