eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programming[asm] i dont (quite) get it › Re: [asm] i dont (quite) get it
  • X-Received: by 10.140.101.199 with SMTP id u65mr28422qge.10.1404730192436; Mon, 07
    Jul 2014 03:49:52 -0700 (PDT)
    X-Received: by 10.140.101.199 with SMTP id u65mr28422qge.10.1404730192436; Mon, 07
    Jul 2014 03:49:52 -0700 (PDT)
    Path: news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.
    atman.pl!goblin2!goblin.stu.neva.ru!feeder.erje.net!us.feeder.erje.net!news.glo
    rb.com!hn18no4439945igb.0!news-out.google.com!a8ni6410qaq.1!nntp.google.com!w8n
    o6605544qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-ma
    il
    Newsgroups: pl.comp.programming
    Date: Mon, 7 Jul 2014 03:49:52 -0700 (PDT)
    In-Reply-To: <a...@g...com>
    Complaints-To: g...@g...com
    Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.154.143.26;
    posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
    NNTP-Posting-Host: 93.154.143.26
    References: <a...@g...com>
    User-Agent: G2/1.0
    MIME-Version: 1.0
    Message-ID: <6...@g...com>
    Subject: Re: [asm] i dont (quite) get it
    From: firr <p...@g...com>
    Injection-Date: Mon, 07 Jul 2014 10:49:52 +0000
    Content-Type: text/plain; charset=ISO-8859-2
    Content-Transfer-Encoding: quoted-printable
    Xref: news-archive.icm.edu.pl pl.comp.programming:206235
    [ ukryj nagłówki ]

    wogole wlasnie ta forma z tymi 'końcówkami' (nawet nie wiem jak to nazwac) dla inline
    assembly w gcc wydaje mi sie w sumie fatalna

    co to ma byc

    void sse_dot(float vec1[4], float vec2[4], float* result) {
    __asm__ volatile (
    "movups (%0), %%xmm0 \n" // load vec1: |w1|z1|y1|x1|
    "movups (%1), %%xmm1 \n" // load vec2: |w2|z2|y2|x2|
    " \n"
    "mulps %%xmm1, %%xmm0 \n" // xmm0 := |w1*w2|z1*z2|y1*y2|x1*x2|
    "movhlps %%xmm0, %%xmm1 \n" // xmm1 := | . | . |w1*w2|z1*z2|
    "addps %%xmm0, %%xmm1 \n" // xmm1 := | . | . | w+y | z+x |
    "movaps %%xmm1, %%xmm0 \n" // save xmm1
    "shufps $0x01, %%xmm1, %%xmm1 \n" // xmm1 := | . | . | . | w+y |
    "addss %%xmm1, %%xmm0 \n" // xmm0[0] := dot product
    "movss %%xmm0, (%2) \n"
    :
    : "r" (vec1), "r" (vec2), "r" (result));
    }

    juz o wiele lepiej wyglada tow czystym asmie
    przynajmniej wszystko jasne


    Dump of assembler code for function sse_dot(float*, float*, float*):
    0x000000a0 <+0>: mov 0xc(%esp),%ecx
    0x000000a4 <+4>: mov 0x8(%esp),%edx
    0x000000a8 <+8>: mov 0x4(%esp),%eax
    0x000000ac <+12>: movups (%eax),%xmm0
    0x000000af <+15>: movups (%edx),%xmm1
    0x000000b2 <+18>: mulps %xmm1,%xmm0
    0x000000b5 <+21>: movhlps %xmm0,%xmm1
    0x000000b8 <+24>: addps %xmm0,%xmm1
    0x000000bb <+27>: movaps %xmm1,%xmm0
    0x000000be <+30>: shufps $0x1,%xmm1,%xmm1
    0x000000c2 <+34>: addss %xmm1,%xmm0
    0x000000c6 <+38>: movss %xmm0,(%ecx)
    0x000000ca <+42>: ret
    End of assembler dump.

    aczkolwiek ani jedna ani druga (czyli ta ms vs gcc) skladnia mi sie nie podoba i
    wolalbym uzywac jakiejs swojej o wiele lepszej

    // function sse_dot(float*, float*, float*)

    mov ecx (!c)
    mov edx (!8)
    mov eax (!4)
    mov-u-ps x0 eax
    mov-u-ps x1 edx
    mul-ps x0 x1
    mov-hl-ps x1 x0
    add-ps x1 x0
    mov-a-ps x0 x1
    shuf-ps x1 x1 1
    add-ss x0 x1
    mov-ss (ecx) x0
    ret

    tj nawrzucalbym troche skrótów np (!c) dla trzeciego inta na stosie itd - byloby
    ladniej

    (niestety nie chce mi sie pisac asemblera, te tabele rozkazow sa za dlugie) - szkoda
    ze nie mam tyle kasy zeby komus zaplacic za napisanie tego , ciekawe ile musialbym
    wybulic za taki skromny ale dzialajacy asembler, nie jest to az tak duzo roboty w
    miesiac chyba mozna by sie uwinąć



Podziel się

Poleć ten post znajomemu poleć

Wydrukuj ten post drukuj


Następne wpisy z tego wątku

Najnowsze wątki z tej grupy


Najnowsze wątki

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: