summaryrefslogtreecommitdiff
path: root/3/11_floating_point/53_funct1.c
blob: 8147b628696f8b3b8e3544fc4d8bc3efb3a66cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
typedef arg1_t int;
typedef arg2_t double;
typedef arg3_t double;

typedef arg4_t double;
double funct1(arg1_t p, arg2_t q, arg3_t r, double s)
{
    return p/(q+r) - s;
}
// funct 1:
//      vcvtsi2ssq      %rsi, %xmm2, %xmm2          convert long to double?
//      vaddss          %xmm0, %xmm2, %xmm0         xmm0 <- xmm2 + xmm0 (q+r)
//      vcvtsi2ss       %edi, %xmm2, %xmm2          convert to float (p)
//      vdivss          %xmm0, %xmm2, %xmm0         xmm0 <- xmm2 (p float) / xmm0 (q+r float)
//      vunpcklps       %xmm0, %xmm0, %xmm0         convert float to double?
//      vcvtps2pd       %xmm0, %xmm0                convert float to double?
//      vsubsd          %xmm1, %xmm0, %xmm0         xmm0 <- xmm0 - (double) s?
//      ret

// s must be in xmm1, it's only used at the end to subtract from xmm0, it must also be double since vsubsd is used
//
// p                                q                   r                   q+r                 p/(q+r)
// rdi, int, since it's             xmm0, float         rsi, long           float, xmm0         float, xmm0
//      converted
//      on line 3
//
// rdi, int, since it's             rsi, long          xmm0, float          float, xmm0         float, xmm0
//      converted
//      on line 3