Script started on Wed 07 Nov 2012 08:12:09 PM EST linux1% gcc -Wall -c -g doarray.c linux1% nasm -f elf -g main.asm linux1% gcc main.o doarray.o linux1% gdb a.out GNU gdb (GDB) Red Hat Enterprise Linux (7.2-48.el6) Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-redhat-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /afs/umbc.edu/users/c/h/chang/home/cs313/Fall2012/proj7/ex/a.out...done. (gdb) list 1 ; File: main.asm 2 ; 3 ; Example that calls do_array() 4 ; 5 6 7 8 SECTION .data ; initialized data section 9 array: dd 7, 9, 2, 4, 8 10 (gdb) list 11 12 SECTION .text 13 extern do_array 14 global main 15 16 main: 17 push ebp ; set up stack frame 18 mov ebp,esp 19 20 before: (gdb) break before Breakpoint 1 at 0x80483a3: file main.asm, line 21. (gdb) list 21 push add3 ; function "pointer" 22 push dword 5 23 push array 24 call do_array 25 add esp, 12 26 27 after: 28 29 mov esp, ebp ; takedown stack frame 30 pop ebp (gdb) list 31 ret 32 33 ; 34 ; End of main() 35 ; 36 37 38 ; function prototype for add1 is: 39 ; int add3(int n) 40 (gdb) break after Breakpoint 2 at 0x80483bd: file main.asm, line 29. (gdb) run Starting program: /afs/umbc.edu/users/c/h/chang/home/cs313/Fall2012/proj7/ex/a.out Breakpoint 1, before () at main.asm:21 21 push add3 ; function "pointer" (gdb) x/5wd &array 0x804967c : 7 9 2 4 0x804968c: 8 (gdb) cont Continuing. Breakpoint 2, after () at main.asm:29 29 mov esp, ebp ; takedown stack frame (gdb) x/5wd &array 0x804967c : 10 12 5 7 0x804968c: 11 (gdb) cont Continuing. Program exited with code 05. (gdb) quit linux1% exit Script done on Wed 07 Nov 2012 08:14:03 PM EST