Woo... porobiło się :P aż nie wiem od czego zacząć
1. Printf i długi if
#include <cstdio>
int main()
{
int ala = 11;
int tom;
if( ala > 10 )
{
tom = true;
}
else
{
tom = false;
}
printf( "%d%d", ala, tom );
return 0;
}
.file "ala.cpp"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "%d%d\0"
.text
.align 2
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
call __alloca
call ___main
movl $LC0, (%esp)
movl $1, %edx
movl $11, %eax
movl %edx, 8(%esp)
movl %eax, 4(%esp)
call _printf
leave
xorl %eax, %eax
ret
.def _printf; .scl 2; .type 32; .endef
Linii:
28 2. Printf i krótki if
#include <cstdio>
int main()
{
int ala = 11;
int tom;
tom = false;
if( ala > 10 )
{
tom = true;
}
printf( "%d%d", ala, tom );
return 0;
}
.file "ala.cpp"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "%d%d\0"
.text
.align 2
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
call __alloca
call ___main
movl $LC0, (%esp)
movl $1, %edx
movl $11, %eax
movl %edx, 8(%esp)
movl %eax, 4(%esp)
call _printf
leave
xorl %eax, %eax
ret
.def _printf; .scl 2; .type 32; .endef
Linii:
28 3. Printf i operator
#include <cstdio>
int main()
{
int ala = 11;
int tom;
tom =( ala > 10 ) ? true
: false;
printf( "%d%d", ala, tom );
return 0;
}
.file "ala.cpp"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "%d%d\0"
.text
.align 2
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
call __alloca
call ___main
movl $LC0, (%esp)
movl $1, %edx
movl $11, %eax
movl %edx, 8(%esp)
movl %eax, 4(%esp)
call _printf
leave
xorl %eax, %eax
ret
.def _printf; .scl 2; .type 32; .endef
Linii:
28 4. Cout i operator
#include <iostream>
int main()
{
int ala = 11;
int tom;
tom =( ala > 10 ) ? true
: false;
std::cout << ala << tom;
return 0;
}
.file "ala.cpp"
.section .ctors,"w"
.align 4
.long __GLOBAL__I_main
.section .dtors,"w"
.align 4
.long __GLOBAL__D_main
.lcomm __ZSt8__ioinit,16
.def ___main; .scl 2; .type 32; .endef
.text
.align 2
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
call __alloca
call ___main
movl __ZSt4cout, %edx
movl -12(%edx), %eax
addl $__ZSt4cout, %eax
movl 12(%eax), %eax
testb $64, %al
jne L5
testb $8, %al
je L4
L5:
movl $__ZSt4cout, (%esp)
movl $11, %ecx
movl %ecx, 4(%esp)
call __ZNSolsEm
L18:
movl %eax, %edx
movl (%eax), %eax
movl -12(%eax), %ecx
leal (%edx,%ecx), %eax
movl 12(%eax), %eax
testb $64, %al
jne L13
testb $8, %al
je L12
L13:
movl %edx, (%esp)
movl $1, %ecx
movl %ecx, 4(%esp)
call __ZNSolsEm
leave
xorl %eax, %eax
ret
.p2align 4,,7
L4:
movl $__ZSt4cout, (%esp)
movl $11, %edx
movl %edx, 4(%esp)
call __ZNSolsEl
jmp L18
.p2align 4,,7
L12:
movl %edx, (%esp)
movl $1, %eax
movl %eax, 4(%esp)
call __ZNSolsEl
leave
xorl %eax, %eax
ret
.align 2
.p2align 4,,15
.def __Z41__static_initialization_and_destruction_0ii; .scl 3; .type 32; .endef
__Z41__static_initialization_and_destruction_0ii:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl %ebx, -8(%ebp)
cmpl $65535, %edx
sete %bl
movl %esi, -4(%ebp)
cmpl $1, %eax
movl %eax, %esi
sete %al
testb %al, %bl
jne L23
testl %esi, %esi
sete %dl
testb %dl, %bl
jne L24
L20:
movl -8(%ebp), %ebx
movl -4(%ebp), %esi
movl %ebp, %esp
popl %ebp
ret
.p2align 4,,7
L23:
movl $__ZSt8__ioinit, (%esp)
call __ZNSt8ios_base4InitC1Ev
testl %esi, %esi
sete %dl
testb %dl, %bl
je L20
.p2align 4,,15
L24:
movl $__ZSt8__ioinit, (%esp)
call __ZNSt8ios_base4InitD1Ev
movl -8(%ebp), %ebx
movl -4(%ebp), %esi
movl %ebp, %esp
popl %ebp
ret
.align 2
.p2align 4,,15
.def __GLOBAL__I_main; .scl 3; .type 32; .endef
__GLOBAL__I_main:
pushl %ebp
movl $65535, %edx
movl %esp, %ebp
popl %ebp
movl $1, %eax
jmp __Z41__static_initialization_and_destruction_0ii
.align 2
.p2align 4,,15
.def __GLOBAL__D_main; .scl 3; .type 32; .endef
__GLOBAL__D_main:
pushl %ebp
movl $65535, %edx
movl %esp, %ebp
popl %ebp
xorl %eax, %eax
jmp __Z41__static_initialization_and_destruction_0ii
.def __ZNSt8ios_base4InitD1Ev; .scl 3; .type 32; .endef
.def __ZNSolsEl; .scl 3; .type 32; .endef
.def __ZNSolsEm; .scl 3; .type 32; .endef
.def __ZNSt8ios_base4InitC1Ev; .scl 3; .type 32; .endef
Linii:
138 @DejaVu
Chyba niestety nie. Pierwsze trzy kody mają po 28 dlatego że wcale nie trzeba sprawdzać warunku, on zawsze będzie taki sam, można go wywalić, i chyba to się dzieje, trzeba by dać losową wartość albo pytać użytkownika :( kolejne 3 kompilacje?
To może tak na szybko... Bo widzę że w kodzie z printf całe printf to "call _printf" a do cout pakuje wszystko... Poszukam kodu funkcji printf xD