CMSI 284 Quiz 2 Preparation =========================== To prepare, work on these four problems. Your quiz will have similar problems: 1. Write the following in assembly language (use the C calling convention). It is supposed to compute a*log3(b)+c. double f(double a, double b, double c); 2. Give all possible encodings of sar dword [ebx+ebp+20], 1. 3. Explain each byte of the following machine language instructions. That is, for each byte, state if it is a prefix (and if so, which one), opcode (and if so, which one or part of one), modrm byte (and if so, show and describe each part in binary), SIB byte (and if so, show and describe each part in binary), displacement, or immediate. For example, given 0F 02 75 00, you would write: 0f 02 => opcode for LAR 75 (01110101) => modr/m, 01:reg+disp8, 110:spare is 6 => esi, 101: ebp 00 => 8 bit displacement with value 0 Result => LAR esi, [ebp+0] a) lock repe punpckhdq xmm6, [esp+8*ebp+1024] (F0F3660F6AB4EC00040000) b) rep cvttsd2si esp, [4*ecx+2] (F3F20F2C248D02000000) c) imul ebx, [ebp], 257 (695D0001010000) 4. Write a C function that takes in a string s and an integer k, and returns a new string containing every kth character in s. For example: f("Go to the beach", 3) ==> "Gtt a" f("Whatever", 2) ==> "Waee" f("This function is really weird", 5) ==> "Tfisle"