Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Code 2. Have a look at the assembly code and explain what is being done here.

ID: 3600589 • Letter: C

Question

C Code

2. Have a look at the assembly code and explain what is being done here. Instead of explaining verbosely, you can write a c code to explain that (hints: this function is returning some value). (10) Assignment method pushl %ebp movl %esp,%ebp pushl %ebx movl 12(%ebp),%ecx movl 8(%ebp),%edx movl 4(%ebp),%esi movl (%ecx),%eax xori %edx, %eax andi %esi, %eax movl-4(%ebp),%ebx movl %ebp,%esp popl %ebp ret

Explanation / Answer

> gcc -g -c test.c > objdump -d -M intel -S test.o test.o: file format elf32-i386 Disassembly of section .text: 00000000 : #include int main(void) { 0: 55 push ebp 1: 89 e5 mov ebp,esp 3: 83 e4 f0 and esp,0xfffffff0 6: 83 ec 10 sub esp,0x10 puts("test"); 9: c7 04 24 00 00 00 00 mov DWORD PTR [esp],0x0 10: e8 fc ff ff ff call 11 return 0; 15: b8 00 00 00 00 mov eax,0x0 } 1a: c9 leave 1b: c3 ret