CMSI 284 Preparation for the Final ================================== To prepare, take this exam. See if you can finish in two hours. 1. Convert the following UTF-32 encoded codepoints to UTF-8 (Express your answer in hex): 000369F5 ____________________________ 0000E09A ____________________________ 00000080 ____________________________ 2. Give the single precision IEEE-754 encoding of 514.625 and explain your answer. 3. Give x86 logic operations to perform the following operations on the esi register (assuming that it contains an unsigned number). Complement the two highest order bits ___________________________________ Replace it with its value mod 64 _______________________________________ Replace it with the largest multiple of 8 less than or equal to itself ______________________________________ 4. Explain in great detail why the decoding of the IA-32 machine instruction F0F30F1414C581FFFFFF is lock repe unpcklps xmm2, [8*eax-127] 5. Write a C function that takes in a string s and an int k and returns a newly allocated string containing sk. In case you haven't seen that notation before, here's an example: ho3 = hohoho. A hint you shouldn't need: Use malloc, strcpy and strcat... or strncpy and strncat if you can't stand the sight of the n-less versions. Hint: Be very careful about the '\0' at the end. 6. Write, in assembly language, a function to exchange each of the characters at even numbered positions (the first position is 0) with their successors, that is intended to be called from C. The function should turn "abcdefghij" into "badcfehgji". Actually swap the characters in the string; don't return a new string. 7. Write a standalone program, using Linux system calls and no external libraries at all, that applies the Caesar cipher with a key of 3 to standard input writing the ciphertext to standard output. Reading is done with system call 3, which accepts, in order the following parameters: the file handle, the address of the buffer to read into, and the number of bytes to read. It returns the number of bytes actually read. The file handle for standard input is 0. You already know about the write system call. (See the web for the definition of Caesar cipher). 8. I wrote a program and saw that the machine code in the object file was 31 DB 43 89 D8 C1 E0 01 89 C2 C1 E0 01 B9 16 00 00 00 CD 80 EB EA 79 0A. When it was loaded into memory, however, I noticed it was 31 DB 43 89 D8 C1 E0 01 89 C2 C1 E0 01 B9 8A 80 04 08 CD 80 EB EA 79 0A. Explain the difference. What memory location was the program loaded at? For extra credit, what program is this? 9. What is the intent of this following function? mystery: call helper ret helper: mov eax, [esp] sub eax, 5 ret Note that superficial, obvious observations like "it calls a function that returns 5 less than the value on the stack top" will earn you zero points. Tell me intent of the code, then tell me a much simpler way to do that.