Last active
January 1, 2016 05:59
-
-
Save lydonchandra/8102311 to your computer and use it in GitHub Desktop.
parameter passing amd64bin gcc osx
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
__m128 __attribute__ ((noinline)) test_parameterPassing( | |
__m128 m128param1, //%xmm0 | |
unsigned u1, //%edi | |
float f1, float f2, //%xmm1, %xmm2 | |
unsigned u2, unsigned u3, //%esi, %edx | |
double d1, double d2, //%xmm3, %xmm4 | |
unsigned u4, unsigned u5, //%ecx, %r8d | |
double d3, double d4, double d5, double d6, //%xmm5, %xmm6, %xmm7, stack | |
unsigned u6, unsigned u7, unsigned u8 //%r9d, stack, stack | |
) { | |
unsigned unsignedResult = u1 + u2 + u3 + u4 + u5 + u6 + u7 +u8; | |
//addl %esi, %edi | |
//addl %edx, %edi | |
//addl %ecx, %edi | |
//addl %r8d, %edi | |
//addl %r9d, %edi | |
//addl 24(%rbp), %edi | |
//addl 32(%rbp), %edi | |
float floatResult = f1/f2; | |
//vdivss %xmm2, %xmm1, %xmm1 | |
double doubleResult = d1 * d2 * d3 * d4 * d5 * d6; | |
//vmulsd %xmm4, %xmm3, %xmm2 | |
//vmulsd %xmm5, %xmm2, %xmm2 | |
//vmulsd %xmm6, %xmm2, %xmm2 | |
//vmulsd %xmm7, %xmm2, %xmm2 | |
//vmulsd 16(%rbp), %xmm2, %xmm2 | |
float result1 = unsignedResult * floatResult * doubleResult; | |
//vcvtsi2ssq %rdi, %xmm0, %xmm3 #convert integer to float | |
//vmulss %xmm1, %xmm3, %xmm1 #multiply as float | |
//vcvtss2sd %xmm1, %xmm1, %xmm1 #convert float to double | |
//vmulsd %xmm1, %xmm2, %xmm1 #multiply as double | |
//vcvtsd2ss %xmm1, %xmm1, %xmm1 #convert back to float | |
__m128 m128obj = _mm_set_ps1(result1); | |
__m128 mulResult = _mm_mul_ps( m128param1, m128obj); | |
//vpshufd $0, %xmm1, %xmm1 | |
//vmulps %xmm0, %xmm1, %xmm0 #pack multiply with m128param1 | |
asm("mov $1, %r11"); | |
return mulResult; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment