Last active
February 1, 2023 22:38
-
-
Save ifknot/4cc1d260f5eb140b4985cd5a45955b75 to your computer and use it in GitHub Desktop.
double precision sum an array single precision floats assembly language 8087 x87 NPX FPU math coprocessor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double sum_array_float(const float* array, uint16_t count) { | |
double sum; | |
__asm { | |
.8086 | |
.8087 | |
mov cx, count | |
jcxz END | |
lds si, array ; ds:[si] points to array of floats size cx | |
fldz | |
ADD_LOOP: | |
fadd dword ptr [si] ; dword is 32 bit single precision float | |
add si, 4 ; IEEE float single precision is 4 bytes | |
loop ADD_LOOP | |
END: | |
fstp sum | |
fwait ; be sure 8087 is done | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment