Assembly Language for Beginners

(Jeff_L) #1

1.8. PRINTF() WITH SEVERAL ARGUMENTS
In certain cases where several functions return right after one another, the compiler could merge multiple
“ADD ESP, X” instructions into one, after the last call:


push a1
push a2
call ...
...
push a1
call ...
...
push a1
push a2
push a3
call ...
add esp, 24

Here is a real-world example:

Listing 1.43: x86
.text:100113E7 push 3
.text:100113E9 call sub_100018B0 ; takes one argument (3)
.text:100113EE call sub_100019D0 ; takes no arguments at all
.text:100113F3 call sub_10006A90 ; takes no arguments at all
.text:100113F8 push 1
.text:100113FA call sub_100018B0 ; takes one argument (1)
.text:100113FF add esp, 8 ; drops two arguments from stack at once
Free download pdf