Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.8 kB
4
Indexable
Never
;extern "C" void sse_add(float* a, float* b, float* result);
sse_add proc
    movaps xmm0, xmmword ptr [rcx];
    addps xmm0, xmmword ptr [rdx];
    movaps [r8], xmm0 
    ret
sse_add endp

;extern void sse_mul(float* a, float* b, float* result);
sse_mul proc
    movaps xmm0, xmmword ptr [rcx];
    mulps xmm0, xmmword ptr [rdx];
    movaps [r8], xmm0 
    ret
sse_mul endp

;extern void sse_sqrt(float* a, float* result);
sse_sqrt proc
    sqrtps xmm0, xmmword ptr [rcx];
    movaps [rdx], xmm0 
    ret
sse_sqrt endp


avx_add proc
    vmovaps ymm0, ymmword ptr [rcx];
    vaddps ymm0, ymm0, ymmword ptr [rdx];
    vmovaps [r8], ymm0 
    ret
avx_add endp

avx_mul proc
    vmovaps ymm0, ymmword ptr [rcx];
    vmulps ymm0, ymm0, ymmword ptr [rdx];
    vmovaps [r8], ymm0 
    ret
avx_mul endp

avx_sqrt proc
    vsqrtps ymm0, ymmword ptr [rcx];
    vmovaps [rdx], ymm0 
    ret
avx_sqrt endp

scalaradd proc
        fld qword ptr [rcx]    ; Load *a into FPU stack
        fadd qword ptr [rdx]   ; Add *b to FPU stack
        fstp qword ptr [r8]   ; Store result in *result and pop from FPU stack
        ret
scalaradd endp

;extern void sse_mul(float* a, float* b, float* result);
scalarmul proc
        fld qword ptr [rcx]    ; Load *a into FPU stack
        fmul qword ptr [rdx]   ; Multiply *b to FPU stack
        fstp qword ptr [r8]   ; Store result in *result and pop from FPU stack
        ret
scalarmul endp

;extern void sse_sqrt(float* a, float* result);
scalarsqrt proc
        fld qword ptr [rcx]    ; Load *a into FPU stack
        fsqrt                  ; Calculate square root
        fstp qword ptr [rdx]   ; Store result in *result and pop from FPU stack
        ret
scalarsqrt endp
Leave a Comment