Open captbaritone opened 4 years ago
Here's the assembly used in the actual implementation: https://github.com/WACUP/vis_milk2/blob/de9625a89e724afe23ed273b96b8e48496095b6c/ns-eel2/asm-nseel-x86-gcc.c#L507-L531
void nseel_asm_mod(void)
{
__asm__(
"fld" EEL_F_SUFFIX " (%edi)\n"
"fld" EEL_F_SUFFIX " (%eax)\n"
"fabs\n"
"fistpl (%esi)\n"
"fabs\n"
"fistpl 4(%esi)\n"
"xorl %edx, %edx\n"
#ifdef TARGET_X64
"subl %eax, %eax\n"
#endif
"cmpl $0, (%esi)\n"
"je 0f\n" // skip devide, set return to 0
"movl 4(%esi), %eax\n"
"divl (%esi)\n"
"0:\n"
"movl %edx, (%esi)\n"
"fildl (%esi)\n"
"movl %esi, %eax\n"
"fstp" EEL_F_SUFFIX " (%esi)\n"
"addl $" EEL_F_SSTR ", %esi\n"
);
}
Auto-close was due to a typo in commit message
Trying compile C's
fmod
to wasm results in dramatically more code:Try the following in https://webassembly.studio/
And you will get the following
wat
: