• Shortest way to code a standard deviation calculation

    From Robert Prins@robert@prino.org to alt.lang.asm on Wed Sep 23 14:15:56 2026
    From Newsgroup: alt.lang.asm

    Basically:

    sqrt((_w * w8wtimesq - sqr(wtime)) / (_w * pred(_w))) * 60 + 0.5

    where all variables are longint. I already figured out that a pure integer square root is not accurate enough. I'd like to use only the normal 32-bits registers, but am open to using the "new"-fangled SSEx stuff, as that would free
    up the FPU and stop me from EMMS'ing it as I also use MMX, because XMM registers
    are trashed by W7 when allocating memory.

    Thanks,

    Robert
    --
    Robert AH Prins
    robert(a)prino(d)org
    The hitchhiking grandfather @ https://prino.neocities.org/
    Some useful(?) REXX @ https://prino.neocities.org/zOS/zOS-Tools.html
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Robert Prins@robert@prino.org to alt.lang.asm on Wed Sep 23 14:27:44 2026
    From Newsgroup: alt.lang.asm

    On 2026-09-23 14:15, Robert Prins wrote:
    Basically:

    sqrt((_w * w8wtimesq - sqr(wtime)) / (_w * pred(_w))) * 60 + 0.5

    where all variables are longint. I already figured out that a pure integer square root is not accurate enough. I'd like to use only the normal 32-bits registers, but am open to using the "new"-fangled SSEx stuff, as that would free
    up the FPU and stop me from EMMS'ing it as I also use MMX, because XMM registers
    are trashed by W7 when allocating memory.

    Additional: This is what I have now:

    FPU:

    emms
    fild dword ptr [eax]
    fld st
    fimul dword ptr w8wtimesq
    fild dword ptr [eax + offset waitwtime]
    fmul st, st
    fsubp
    fxch
    fld st
    fmul st(1), st(0)
    fsubp
    fdivp
    fsqrt
    fmul dword ptr d_60v0
    fadd dword ptr d_0v5
    fisttp dword ptr [esp]

    SSEx, much longer in code-size...

    cvtsi2sd xmm1, dword ptr [eax + offset waitwtime]
    cvtsi2sd xmm2, dword ptr [w8wtimesq]
    mulsd xmm2, xmm0
    mulsd xmm1, xmm1
    subsd xmm2, xmm1
    movsd xmm3, xmm0
    movsd xmm1, qword ptr [d_1v0]
    subsd xmm3, xmm1
    mulsd xmm3, xmm0
    divsd xmm2, xmm3
    sqrtsd xmm2, xmm2
    mulsd xmm2, qword ptr [d_60v0]
    addsd xmm2, qword ptr [d_0v5]
    cvttsd2si eax, xmm2
    mov [esp], eax

    Robert
    --
    Robert AH Prins
    robert(a)prino(d)org
    The hitchhiking grandfather @ https://prino.neocities.org/
    Some useful(?) REXX @ https://prino.neocities.org/zOS/zOS-Tools.html

    --- Synchronet 3.22a-Linux NewsLink 1.2