Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
callingFunctions.S
Search
Pat Hawks
October 04, 2014
Education
130
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
callingFunctions.S
Pat Hawks
October 04, 2014
More Decks by Pat Hawks
See All by Pat Hawks
I ♥ Swift
pathawks
0
120
Choosing an Open Source Software License
pathawks
0
73
A Brief Introduction to Magic
pathawks
0
65
callReturnExploration.s
pathawks
0
60
Grokking Signed Overflows
pathawks
0
63
Other Decks in Education
See All in Education
[2026前期火5] 論理学(京都大学文学部 前期 第9回)「正規化の停止性——ヒドラゲームによる証明」
yatabe
0
130
コミュニティを通じた_キャリア設計のススメ_20260424.pdf
masakiokuda
0
330
Interaction - Lecture 10 - Information Visualisation (4019538FNR)
signer
PRO
0
2.7k
[2026前期火5] 論理学(京都大学文学部 前期 第10回)「論理学の哲学——意味とは何か(Tonkと推論主義)」
yatabe
0
140
We部コミュニティスライド2026-04-24
junhat6
0
190
Examen de Selectividad. Geografía junio 2026 (Convocatoria Ordinaria). UCLM
juanmartin2026
0
470
[2026前期火5] 論理学(京都大学文学部 前期 第4回)「 ならば(→)の導入と証明ネット」
yatabe
0
470
参加制約理論
roadofhope
0
120
0506
cbtlibrary
0
200
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019538FNR)
signer
PRO
1
2.7k
[2026前期火5] 論理学(京都大学文学部 前期 第2回)「論理的な正しさはどこにあるのか」
yatabe
0
970
現場最前線から教えるデータサイエンス1 -ITベンダーにおけるデータサイエンティスト-
hidetoshikawaguchi
0
110
Featured
See All Featured
The agentic SEO stack - context over prompts
schlessera
0
820
Building an army of robots
kneath
306
46k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
220
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
We Have a Design System, Now What?
morganepeng
55
8.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
370
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Amusing Abliteration
ianozsvald
1
210
Transcript
callingFunctions.S Passing arguments to functions via the stack
LC0: .ascii "The argument was %d\12\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 8(%esp) argv 4(%esp) argc (%esp) return addr %esp 28ff2c %ebp old %ebp %eax $0
LC0: .ascii "The argument was %d\12\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 8(%esp) argv 4(%esp) argc (%esp) return addr %esp 28ff2c %ebp old %ebp %eax $0
LC0: .ascii "The argument was %d\12\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 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 %d\12\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 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 %d\12\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 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff28 %ebp 28ff28 %eax $0
LC0: .ascii "The argument was %d\12\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 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff28 %ebp 28ff28 %eax $0
LC0: .ascii "The argument was %d\12\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 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff20 %ebp 28ff28 %eax $0
LC0: .ascii "The argument was %d\12\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 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp %esp 28ff20 %ebp 28ff28 %eax $0
LC0: .ascii "The argument was %d\12\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 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 %d\12\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 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 %d\12\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 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 %d\12\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 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 %d\12\0" %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 %d\12\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 $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