kohlrak icon

Untitled

kohlrak | PRO | 07/17/17 06:41:37 PM UTC | 0 ⭐ | 259 👁️ | Never ⏰ | []
ASM (NASM) |

0 B

|

None

|

0 👍

/

0 👎

C++:
 
int add(int x, int y){
        return x+y;
}
 
g++ output (default):
 
        .globl  _Z3addii
        .type   _Z3addii, @function
_Z3addii:
.LFB0:
        .cfi_startproc
        push    ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        mov     ebp, esp
        .cfi_def_cfa_register 5
        mov     edx, DWORD PTR [ebp+8]
        mov     eax, DWORD PTR [ebp+12]
        add     eax, edx
        pop     ebp
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
 
g++ output (formatting functions removed):
 
_Z3addii: #leaving this here, even though it won't end up in the binary, since i would type it, too.
        push    ebp
        mov     ebp, esp
        mov     edx, DWORD PTR [ebp+8]
        mov     eax, DWORD PTR [ebp+12]
        add     eax, edx
        pop     ebp
        ret
 
g++ output (formatting removed, optimization to maximum):
_Z3addii:
        mov     eax, DWORD PTR [esp+8]
        add     eax, DWORD PTR [esp+4]
        ret
 
my handwritten assembly:
_Z3addii:
    mov eax, [esp+4]
    add eax, [esp+8]
    ret

Comments