flat assembler
Message board for the users of flat assembler.

Index > Main > String length

Goto page Previous  1, 2, 3, 4, 5, 6
Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 16 Jul 2014, 15:34
@denat - it is smaller as a code, but much slower. It is not so important for short strings (on very short strings it may be even faster), but for longer strings it is at least 7..8 times slower. There was test data in the thread.
Post 16 Jul 2014, 15:34
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 16 Jul 2014, 18:42
@offtopic

can we expect that everybody nowdays has a computer with supports for mmx instructions? i see most games/programs still use old instructions only
Post 16 Jul 2014, 18:42
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 16 Jul 2014, 19:38
@randomdude - Check the release dates for SSE/2/3/4 AVX/2 and base your decision on how far back you're willing to support.
Post 16 Jul 2014, 19:38
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 16 Jul 2014, 22:22
randomdude wrote:
@offtopic

can we expect that everybody nowdays has a computer with supports for mmx instructions? i see most games/programs still use old instructions only


It is not exactly offtopic. Actually I also wander whether it is good idea to use MMX and the other newer instruction sets...
For the MMX, the answer is probably "yes". The CPUs without MMX actually are not in use today.
The answer for the remaming: SSE, etc. is not so clear, but most of them are for floating point arithmetics, that is not so widely used in assembly programming (but is still essential for some tasks). So, here one have to decide on case-by-case basis...

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 16 Jul 2014, 22:22
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 17 Jul 2014, 03:22
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 18:05; edited 1 time in total
Post 17 Jul 2014, 03:22
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 17 Jul 2014, 05:37
90% is not enough. IMHO, 99% if the bare minimum and 99.5% is desirable goal.
Post 17 Jul 2014, 05:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 407
Location: Australia
redsock 17 Jul 2014, 06:41
Chiming in after having read through this entire thread... IMO Paul Hsieh covered this pretty well, and while I did see a few "extreme likeness" to his effort and specifically Alan Mycroft/Norbert Juffa, no one seems to have covered it verbatim... in my experimenting, (small) C strings don't benefit from the added SSE* overhead, and still haven't... all of my code uses the following code bit... see Paul's length section re: same at http://www.azillionmonkeys.com/qed/asmexample.html...

$0.02 thusly, hehe

Cheers

Code:
macro calign {
        local a
        virtual
                align 16
                a = $ - $$
        end virtual
        if a = 15
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
                db 0x66, 0xf, 0x1f, 0x44, 0x00, 0x00
        else if a = 14
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
                db 0xf, 0x1f, 0x44, 0x00, 0x00
        else if a = 13
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
                db 0xf, 0x1f, 0x40, 0x00
        else if a = 12
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
                db 0xf, 0x1f, 0x00
        else if a = 11
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
                db 0x66, 0x90
        else if a = 10
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
                db 0x90
        else if a = 9
                db 0x66, 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
        else if a = 8
                db 0xf, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
        else if a = 7
                db 0xf, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
        else if a = 6
                db 0x66, 0xf, 0x1f, 0x44, 0x00, 0x00
        else if a = 5
                db 0xf, 0x1f, 0x44, 0x00, 0x00
        else if a = 4
                db 0xf, 0x1f, 0x40, 0x00
        else if a = 3
                db 0xf, 0x1f, 0x00
        else if a = 2
                db 0x66, 0x90
        else if a = 1
                db 0x90
        end if
}

align 16
strlen_latin1:
        mov     rax, rdi
        sub     rax, 1
calign
.top:
        add     rax, 1
        test    rax, 3
        jnz     .misaligned
calign
.inner:
        mov     ecx, [rax]
        add     rax, 4
        mov     edx, ecx
        not     ecx
        sub     edx, 0x01010101
        and     ecx, 0x80808080
        and     ecx, edx
        jz      .inner
        sub     rax, 4
calign
.misaligned:
        cmp     byte [rax], 0
        jne     .top
        sub     rax, rdi
        ret
    
Post 17 Jul 2014, 06:41
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.