/* To build this: * as call_scanf_optimized.s --32 -o call_scanf.o -g * ld -dynamic-linker /lib/ld-linux.so.2 -lc call_scanf.o -m elf_i386 -g */ .section .data scanf_format: .asciz "%d" printf_format: .asciz "The number you entered was %d\n" .section .text .globl _start _start: mov %esp, %ebp sub $4, %esp mov %esp, %eax pushl %eax pushl $scanf_format call scanf mov -4(%ebp), %ebx // This is a straightforward way to call printf pushl %ebx pushl $printf_format call printf mov $1, %eax mov $0, %ebx int $0x80