SlideShare a Scribd company logo
1 of 41
Download to read offline
callingFunctions.S
Passing arguments to functions via the stack
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
8(%esp) argv
4(%esp) argc
(%esp) return addr
%esp 28ff2c %ebp old %ebp %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
8(%esp) argv
4(%esp) argc
(%esp) return addr
%esp 28ff2c %ebp old %ebp %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%esp) argv
8(%esp) argc
4(%esp) return addr
(%esp) old %ebp
%esp 28ff28 %ebp old %ebp %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%esp) argv
8(%esp) argc
4(%esp) return addr
(%esp) old %ebp
%esp 28ff28 %ebp old %ebp %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
%esp 28ff28 %ebp 28ff28 %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
%esp 28ff28 %ebp 28ff28 %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
%esp 28ff20 %ebp 28ff28 %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
%esp 28ff20 %ebp 28ff28 %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp)
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax $0
LC0:
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp)
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax $0
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp)
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax $0
.ascii "The argument was %d120"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax $0
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax $0
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv
Address of
pointer to
prog name
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv
Address of
pointer to
prog name
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv+4
Address of
pointer to
first arg
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv+4
Address of
pointer to
first arg
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv[1]
pointer to
first arg
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) %esp 28ff00 %ebp 28ff28 %eax argv[1]
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
For our purposes
argv[1] = "67"
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
For our purposes
argv[1] = "67"
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
For our purposes
argv[1] = "67"
_atoi grabs the char array at
the address stored in (%esp),
converts the ASCII string to an
int, and returns the int in %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
For our purposes
argv[1] = "67"
_atoi grabs the char array at
the address stored in (%esp),
converts the ASCII string to an
int, and returns the int in %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $1234
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
andl $-16, %esp
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp)
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
subl $32, %esp
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $67
call ___main
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) $LC0
$LC0 is the location in memory
of our format string.
"The argument was %d120"
%esp 28ff00 %ebp 28ff28 %eax $67
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $67
$LC0 is the location in memory
of our format string.
"The argument was %d120"
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $67
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $0
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
12(%ebp) argv
8(%ebp) argc
4(%ebp) return addr
(%ebp) old %ebp
28(%esp) $67
24(%esp)
20(%esp)
16(%esp)
12(%esp)
8(%esp)
4(%esp) $67
(%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $0
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
8(%esp) argv
4(%esp) argc
(%esp) return addr
%esp 28ff2c %ebp old %ebp %eax $0
8(%esp) argv
4(%esp) argc
(%esp) return addr
%esp 28ff2c %ebp old %ebp %eax $0
movl $1234, 28(%esp)
movl 12(%ebp), %eax
addl $4, %eax
movl (%eax), %eax
movl %eax, (%esp)
call _atoi
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
callingFunctions.S
Passing arguments to functions via the stack
This presentation by Pat Hawks is licensed under a
Creative Commons Attribution 4.0 International License

More Related Content

What's hot

Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6brian d foy
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Contextlichtkind
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP ArraysAhmed Swilam
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smartlichtkind
 
Creating own language made easy
Creating own language made easyCreating own language made easy
Creating own language made easyIngvar Stepanyan
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Workhorse Computing
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoEleanor McHugh
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADDharmalingam Ganesan
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in OptimizationDavid Golden
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Andrew Shitov
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperosfameron
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Workhorse Computing
 
PHP for Python Developers
PHP for Python DevelopersPHP for Python Developers
PHP for Python DevelopersCarlos Vences
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6brian d foy
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic trapsDamien Seguy
 

What's hot (19)

Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP Arrays
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
 
Creating own language made easy
Creating own language made easyCreating own language made easy
Creating own language made easy
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with Go
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in Optimization
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
 
PHP for Python Developers
PHP for Python DevelopersPHP for Python Developers
PHP for Python Developers
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 
07 php
07 php07 php
07 php
 

Similar to Calling Functions

Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N  .LC1 .st.pdfAnswer1).LC0 .string Enter the value of N  .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N .LC1 .st.pdfannaiwatertreatment
 
rop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer securityrop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer securityFannyBellows
 
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docxcs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docxmydrynan
 
AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdf
AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdfAnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdf
AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdfarccreation001
 
LDAP Synchronization Connector (LSC)
LDAP Synchronization Connector (LSC)LDAP Synchronization Connector (LSC)
LDAP Synchronization Connector (LSC)Jonathan Clarke
 
Function Call Optimization
Function Call OptimizationFunction Call Optimization
Function Call Optimizationppd1961
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangSean Cribbs
 
Laziness in Swift
Laziness in Swift Laziness in Swift
Laziness in Swift SwiftWro
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
Latex Symbols.pdf
Latex Symbols.pdfLatex Symbols.pdf
Latex Symbols.pdfKomal526846
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlSway Wang
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
symbols of Latex.pdf
symbols of Latex.pdfsymbols of Latex.pdf
symbols of Latex.pdfMdNaim23
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallySean Cribbs
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lispkyleburton
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 

Similar to Calling Functions (20)

Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N  .LC1 .st.pdfAnswer1).LC0 .string Enter the value of N  .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
 
rop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer securityrop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer security
 
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docxcs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
 
Neatly folding-a-tree
Neatly folding-a-treeNeatly folding-a-tree
Neatly folding-a-tree
 
AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdf
AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdfAnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdf
AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdf
 
LDAP Synchronization Connector (LSC)
LDAP Synchronization Connector (LSC)LDAP Synchronization Connector (LSC)
LDAP Synchronization Connector (LSC)
 
Function Call Optimization
Function Call OptimizationFunction Call Optimization
Function Call Optimization
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
 
Laziness in Swift
Laziness in Swift Laziness in Swift
Laziness in Swift
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
La tex symbols
La tex symbolsLa tex symbols
La tex symbols
 
Symbols
SymbolsSymbols
Symbols
 
Latex Symbols.pdf
Latex Symbols.pdfLatex Symbols.pdf
Latex Symbols.pdf
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
symbols of Latex.pdf
symbols of Latex.pdfsymbols of Latex.pdf
symbols of Latex.pdf
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 

Recently uploaded

Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Calling Functions

  • 1. callingFunctions.S Passing arguments to functions via the stack
  • 2. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 8(%esp) argv 4(%esp) argc (%esp) return addr %esp 28ff2c %ebp old %ebp %eax $0
  • 3. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 8(%esp) argv 4(%esp) argc (%esp) return addr %esp 28ff2c %ebp old %ebp %eax $0
  • 4. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%esp) argv 8(%esp) argc 4(%esp) return addr (%esp) old %ebp %esp 28ff28 %ebp old %ebp %eax $0
  • 5. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%esp) argv 8(%esp) argc 4(%esp) return addr (%esp) old %ebp %esp 28ff28 %ebp old %ebp %eax $0
  • 6. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff28 %ebp 28ff28 %eax $0
  • 7. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff28 %ebp 28ff28 %eax $0
  • 8. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff20 %ebp 28ff28 %eax $0
  • 9. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff20 %ebp 28ff28 %eax $0
  • 10. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax $0
  • 11. LC0: .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax $0
  • 12. .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax $0
  • 13. .ascii "The argument was %d120" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax $0
  • 14. .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax $0
  • 15. .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv
  • 16. .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv Address of pointer to prog name
  • 17. .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv Address of pointer to prog name
  • 18. .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv+4 Address of pointer to first arg
  • 19. .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv+4 Address of pointer to first arg
  • 20. .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv[1] pointer to first arg
  • 21. _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) %esp 28ff00 %ebp 28ff28 %eax argv[1]
  • 22. _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
  • 23. _main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax For our purposes argv[1] = "67" 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
  • 24. pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) For our purposes argv[1] = "67" 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
  • 25. pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) For our purposes argv[1] = "67" _atoi grabs the char array at the address stored in (%esp), converts the ASCII string to an int, and returns the int in %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax argv[1]
  • 26. pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) For our purposes argv[1] = "67" _atoi grabs the char array at the address stored in (%esp), converts the ASCII string to an int, and returns the int in %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 27. movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $1234 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 28. movl %esp, %ebp andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 29. andl $-16, %esp subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 30. subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 31. subl $32, %esp call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 32. call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) argv[1] %esp 28ff00 %ebp 28ff28 %eax $67
  • 33. call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $67
  • 34. call ___main movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) $LC0 $LC0 is the location in memory of our format string. "The argument was %d120" %esp 28ff00 %ebp 28ff28 %eax $67
  • 35. movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $67 $LC0 is the location in memory of our format string. "The argument was %d120"
  • 36. movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $67
  • 37. movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $0
  • 38. movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 28(%esp) $67 24(%esp) 20(%esp) 16(%esp) 12(%esp) 8(%esp) 4(%esp) $67 (%esp) $LC0 %esp 28ff00 %ebp 28ff28 %eax $0
  • 39. movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret 8(%esp) argv 4(%esp) argc (%esp) return addr %esp 28ff2c %ebp old %ebp %eax $0
  • 40. 8(%esp) argv 4(%esp) argc (%esp) return addr %esp 28ff2c %ebp old %ebp %eax $0 movl $1234, 28(%esp) movl 12(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%esp) call _atoi movl %eax, 28(%esp) movl 28(%esp), %eax movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret
  • 41. callingFunctions.S Passing arguments to functions via the stack This presentation by Pat Hawks is licensed under a Creative Commons Attribution 4.0 International License