CSE3101 Fall 2005 Exam #2, open book, open notes. Name __________________ 1. Write an equivalent function in assembler (30 pts): double f(int a, double x) { return (a/x) * 3.0 - 2.0; } ; ANSWER two dq 2.0 ; or two real8 2.0, could also be in data segment three dq 3.0 _f: fild dword ptr [esp+4] ; a (need to specify operand size) fdiv qword ptr [esp+8] ; x fmul [three] ; ("qword ptr" or "real8 ptr" is optional here) fsub [two] ret ; result in st(0) 2. The code below adds two vectors of length n. Write an equivalent function in assembler. You may assume n > 0 (30 pts). void add(double *a, double *b, double *sum, int n) { for (int i=0; i