Skip to content

Instantly share code, notes, and snippets.

@JulWas797
Created July 30, 2023 15:05
Show Gist options
  • Save JulWas797/bc73fd9a4c16e0cf15a3da5cecedaedc to your computer and use it in GitHub Desktop.
Save JulWas797/bc73fd9a4c16e0cf15a3da5cecedaedc to your computer and use it in GitHub Desktop.
Mandelbrot fractal iteration count, made using MASM w/ MultiMedia eXtension SIMD instruction set.
.data
const_4 real8 4.0
const_2 real8 2.0
.code
itrcnt proc, x: real8, y: real8, maxi: dword
xor eax, eax
xorpd mm0, mm0
xorpd mm1, mm1
xorpd mm2, mm2
xorpd mm3, mm3
iteration:
movsd mm4, mm2
subsd mm4, mm3
addsd mm4, [x]
movsd mm5, [const_2]
mulsd mm5, mm0
mulsd mm5, mm1
addsd mm5, [y]
movsd mm0, mm4
movsd mm1, mm5
mulsd mm4, mm4
mulsd mm5, mm5
addsd mm4, mm5
comisd mm4, [const_4]
jae checkcnt
ret
checkcnt:
inc eax
cmp eax, [maxi]
jb iteration
ret
itrcnt endp
end
@JulWas797
Copy link
Author

Quick description for people who don't know assembler

real8 is equavilent to Clang double, while dword is 32-bit int

Instructions refernece

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment