These exercises should help you exercise your assembly reading skills; the best way to is to write simple snippets of code yourself. Note: make sure you write and build assembly code for your actual platform. For 32bit Linux, use "nasm -f elf prog.s" and use 32bit mnemonics, for 64bit, "nasm -f elf64 prog.s", and use the proper calling conventions for system calls (these are very different between the systems, see syscall.txt). HINT: When in doubt about system calls and their arguments, use the "strace" command. It is most useful in the form "strace 2>&1 | less", because by default it sends its output to standard error stream (file descriptor 2) rather than to standard output (fd 1); 2>&1 duplicates fd 2 to fd 1. 0. Warm-up. What does this do? call _foo _foo: pop edx Can you explain the '00 00 00 00' in the binary expression of the call instructions? For example, what would the following code return and why? (note, you will need to pick up its return code with 'echo $?'): ;---------- call-pop.s (download from cs258/examples/) -------- BITS 32 section .text global _start _start: call _bar _bar: pop ecx call _foo _foo: pop ebx sub ebx, ecx mov eax, 1 int 80h ;--------------------------------------------------------------- 1. Write a program than prints the first 100 bytes of a file (say, /etc/issue) to standard output. 2. Write a program that prints the contents of a file (say, /etc/passwd) to standard output. 3. Write a minimal version of 'ls' that prints the names of all files in the current directory (same as the 'ls' command withough any arguments). 4. Write a minimal version of 'ps' that prints the PIDs and names of all processes running on the system. When in doubt, use single-stepping, and "info reg" in GDB to see the effect of an instruction on registers.