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
76
A Brief Introduction to Magic
pathawks
0
66
callReturnExploration.s
pathawks
0
62
Grokking Signed Overflows
pathawks
0
64
Other Decks in Education
See All in Education
0513
cbtlibrary
0
220
2026年度春学期 統計学 第5回 分布をまとめるー記述統計量(平均・分散など) (2026. 5. 7)
akiraasano
PRO
0
220
2026年度春学期 統計学 第6回 データの関係を知る(1)ー 相関関係 (2026. 5. 14)
akiraasano
PRO
0
190
2026年度春学期 統計学 第4回 データを「分布」で見る (2026. 4. 30)
akiraasano
PRO
0
200
Soluciones al examen de Geografía 2026. JULIO (Convocatoria Extraordinaria)
juanmartin2026
1
15k
Stardy 会社紹介資料
stardy
0
3.1k
Examen de Selectividad. Geografía junio 2026 (Convocatoria Ordinaria). UCLM
juanmartin2026
1
2.8k
Portable & Reproducible Research Environments in the Age of AI Agents
denkiwakame
0
510
Course Review - Lecture 13 - Information Visualisation (4019538FNR)
signer
PRO
1
2.7k
Human-AI Interaction - Lecture 11 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.1k
Throw Yourself In! - How I've learned English and What I'm Facing
georgeorge
1
190
[2026前期火5] 論理学(京都大学文学部 前期 第3回)「形式言語と四つのキーワード:メタ・構成・意味論・ハーモニー」
yatabe
0
600
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
370
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Pragmatic Product Professional
lauravandoore
37
7.4k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Building AI with AI
inesmontani
PRO
1
1.1k
The Limits of Empathy - UXLibs8
cassininazir
1
520
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.6k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.7k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Facilitating Awesome Meetings
lara
57
7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
67
56k
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