.file "printf-sample2.c" .section .rodata .LC0: .string "%d" .text .globl read_int .type read_int, @function read_int: pushl %ebp movl %esp, %ebp subl $1064, %esp movl stdin, %eax movl %eax, 8(%esp) movl $1024, 4(%esp) leal -1032(%ebp), %eax movl %eax, (%esp) call fgets testl %eax, %eax jne .L2 movl $0, -1040(%ebp) jmp .L1 .L2: leal -1036(%ebp), %eax movl %eax, 8(%esp) movl $.LC0, 4(%esp) leal -1032(%ebp), %eax movl %eax, (%esp) call sscanf movl -1036(%ebp), %eax movl %eax, -1040(%ebp) .L1: movl -1040(%ebp), %eax leave ret .size read_int, .-read_int .section .rodata .LC2: .string "%f" .text .globl read_float .type read_float, @function read_float: pushl %ebp movl %esp, %ebp subl $1064, %esp movl stdin, %eax movl %eax, 8(%esp) movl $1024, 4(%esp) leal -1032(%ebp), %eax movl %eax, (%esp) call fgets testl %eax, %eax jne .L4 fldz fstps -1040(%ebp) jmp .L3 .L4: leal -1036(%ebp), %eax movl %eax, 8(%esp) movl $.LC2, 4(%esp) leal -1032(%ebp), %eax movl %eax, (%esp) call sscanf movl -1036(%ebp), %eax movl %eax, -1040(%ebp) .L3: flds -1040(%ebp) leave ret .size read_float, .-read_float .section .rodata .LC5: .string "%lf" .text .globl read_double .type read_double, @function read_double: pushl %ebp movl %esp, %ebp subl $1064, %esp movl stdin, %eax movl %eax, 8(%esp) movl $1024, 4(%esp) leal -1032(%ebp), %eax movl %eax, (%esp) call fgets testl %eax, %eax jne .L6 fldz fstpl -1048(%ebp) jmp .L5 .L6: leal -1040(%ebp), %eax movl %eax, 8(%esp) movl $.LC5, 4(%esp) leal -1032(%ebp), %eax movl %eax, (%esp) call sscanf fldl -1040(%ebp) fstpl -1048(%ebp) .L5: fldl -1048(%ebp) leave ret .size read_double, .-read_double .globl read_string .type read_string, @function read_string: pushl %ebp movl %esp, %ebp subl $24, %esp movl stdin, %eax movl %eax, 8(%esp) movl 12(%ebp), %eax movl %eax, 4(%esp) movl 8(%ebp), %eax movl %eax, (%esp) call fgets leave ret .size read_string, .-read_string .section .rodata .LC7: .string "%s" .text .globl print_char .type print_char, @function print_char: pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movb %al, -1(%ebp) movzbl -1(%ebp), %eax movb %al, -4(%ebp) movb $0, -3(%ebp) leal -4(%ebp), %eax movl %eax, 4(%esp) movl $.LC7, (%esp) call printf leave ret .size print_char, .-print_char .section .rodata .LC8: .string "%x %x\n" .text .globl myprintf .type myprintf, @function myprintf: pushl %ebp movl %esp, %ebp subl $24, %esp leal 12(%ebp), %eax movl %eax, -4(%ebp) leal 8(%ebp), %eax movl %eax, 8(%esp) movl -4(%ebp), %eax movl %eax, 4(%esp) movl $.LC8, (%esp) call printf .L10: movl 8(%ebp), %eax cmpb $0, (%eax) jne .L12 jmp .L9 .L12: movl 8(%ebp), %eax cmpb $37, (%eax) jne .L13 incl 8(%ebp) movl 8(%ebp), %eax movsbl (%eax),%eax movl %eax, -8(%ebp) cmpl $100, -8(%ebp) je .L15 cmpl $115, -8(%ebp) je .L16 jmp .L19 .L15: movl -4(%ebp), %eax movl %eax, 4(%esp) movl $.LC0, (%esp) call printf leal -4(%ebp), %eax addl $4, (%eax) jmp .L19 .L16: movl -4(%ebp), %eax movl %eax, 4(%esp) movl $.LC7, (%esp) call printf leal -4(%ebp), %eax addl $4, (%eax) jmp .L19 .L13: movl 8(%ebp), %eax movsbl (%eax),%eax movl %eax, (%esp) call print_char .L19: incl 8(%ebp) jmp .L10 .L9: leave ret .size myprintf, .-myprintf .section .rodata .LC9: .string "OK" .LC10: .string "TEST %d is %s ...\n" .LC11: .string "All done\n" .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $24, %esp andl $-16, %esp movl $0, %eax subl %eax, %esp movl $.LC9, 8(%esp) movl $99, 4(%esp) movl $.LC10, (%esp) call myprintf movl $.LC11, 4(%esp) movl $.LC7, (%esp) call printf movl $0, %eax leave ret .size main, .-main .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-13)"