flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
MHajduk 07 Nov 2013, 11:20
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 07 Nov 2013, 11:27
It is FreshLib syntax. The procedure header can be easily edited for whatever macro library you use.
|
|||
![]() |
|
MHajduk 07 Nov 2013, 12:25
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 07 Nov 2013, 13:03
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 07 Nov 2013, 13:16
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 07 Nov 2013, 13:17
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 19:10; edited 1 time in total |
|||
![]() |
|
ejamesr 09 Nov 2013, 22:32
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 10 Nov 2013, 05:10
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 11 Nov 2013, 21:55
'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-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.