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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Πλουτοκρατία: Η Τυραννία του Μαμμωνά και η Μεταανθρώπινη Δουλεία
amethyst1
0
270
共感から、つくる: 変わり続ける自分と、誰かのための創造
micknerd
1
400
2026年度春学期 統計学 第5回 分布をまとめるー記述統計量(平均・分散など) (2026. 5. 7)
akiraasano
PRO
0
150
0526
cbtlibrary
0
170
AWS Certified Generative AI Developer - Professional Beta 不合格体験記
amarelo_n24
1
390
The Art & Science of Elearning
tmiket
1
220
輻射安全管理系統2.0暨輻防e++學園平台說明會
aecrp
0
1k
Modern Data Fetching Techniques in Angular
debug_mode
0
220
勾配ブースティングと決定木の話 / gradient boosting and decision trees
kaityo256
PRO
6
1.3k
プロポーザルを書く技術とアンチパターン/proposal-writing-and-antipatterns
moriyuya
13
3.5k
Case Studies and Future Research - Lecture 12 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
180
【セーフィー】テクニカルライティング&コミュニケーション実践講座(26新卒エンジニア向け研修資料)
ymzaki_m4
0
230
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Visualization
eitanlees
152
17k
The Curse of the Amulet
leimatthew05
2
13k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
740
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Marketing to machines
jonoalderson
1
5.5k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
440
Paper Plane (Part 1)
katiecoart
PRO
0
9.2k
Everyday Curiosity
cassininazir
0
240
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
150
Code Reviewing Like a Champion
maltzj
528
40k
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