diff options
| author | Mike Vink <mike@pionative.com> | 2024-07-09 09:06:58 +0200 |
|---|---|---|
| committer | Mike Vink <mike@pionative.com> | 2024-07-09 09:06:58 +0200 |
| commit | 7ae6aa6a64f3f697edb90bb573862bf31dd14e69 (patch) | |
| tree | e80f43394fd5814e30f98a7faa189f8f49424681 /3/11_floating_point/53_funct1.c | |
| parent | 8092f4c334db547ced59d6f439b558dad35e1ab2 (diff) | |
chapter 3: reading excercises + attacklab
Diffstat (limited to '3/11_floating_point/53_funct1.c')
| -rw-r--r-- | 3/11_floating_point/53_funct1.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/3/11_floating_point/53_funct1.c b/3/11_floating_point/53_funct1.c new file mode 100644 index 0000000..8147b62 --- /dev/null +++ b/3/11_floating_point/53_funct1.c @@ -0,0 +1,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 |
