Skip to content

Instantly share code, notes, and snippets.

@Bigtalljosh
Last active March 26, 2019 14:02
Show Gist options
  • Save Bigtalljosh/75f73c4e97eebb338080870042bf0a46 to your computer and use it in GitHub Desktop.
Save Bigtalljosh/75f73c4e97eebb338080870042bf0a46 to your computer and use it in GitHub Desktop.

Revisions

  1. Bigtalljosh revised this gist Mar 26, 2019. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions Simple C++ to show off in Assembly.
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,12 @@
    int square(int num);

    int main( int argc, const char* argv[] )
    int main(int argc, const char* argv[])
    {
    int result = square(10);
    }

    int square(int num) {
    int square(int num)
    {
    return num * num;
    }

  2. Bigtalljosh revised this gist Jan 29, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion Simple C++ to show off in Assembly.
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,6 @@ int main( int argc, const char* argv[] )
    int result = square(10);
    }

    // Type your code here, or load an example.
    int square(int num) {
    return num * num;
    }
  3. Bigtalljosh created this gist Nov 14, 2016.
    34 changes: 34 additions & 0 deletions Simple C++ to show off in Assembly.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    int square(int num);

    int main( int argc, const char* argv[] )
    {
    int result = square(10);
    }

    // Type your code here, or load an example.
    int square(int num) {
    return num * num;
    }



    main:
    push rbp
    mov rbp, rsp
    sub rsp, 32
    mov DWORD PTR [rbp-20], edi
    mov QWORD PTR [rbp-32], rsi
    mov edi, 10
    call square(int)
    mov DWORD PTR [rbp-4], eax
    mov eax, 0
    leave
    ret
    square(int):
    push rbp
    mov rbp, rsp
    mov DWORD PTR [rbp-4], edi
    mov eax, DWORD PTR [rbp-4]
    imul eax, DWORD PTR [rbp-4]
    pop rbp
    ret