From 7ae6aa6a64f3f697edb90bb573862bf31dd14e69 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Tue, 9 Jul 2024 09:06:58 +0200 Subject: chapter 3: reading excercises + attacklab --- 3/11_floating_point/53_funct1.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 3/11_floating_point/53_funct1.c (limited to '3/11_floating_point/53_funct1.c') 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 -- cgit v1.2.3