Skip to content

Instantly share code, notes, and snippets.

@yellowbyte
Last active May 1, 2026 05:18
Show Gist options
  • Select an option

  • Save yellowbyte/d91da3c3b0bc3ee6d1d1ac5327b1b4b2 to your computer and use it in GitHub Desktop.

Select an option

Save yellowbyte/d91da3c3b0bc3ee6d1d1ac5327b1b4b2 to your computer and use it in GitHub Desktop.

Revisions

  1. yellowbyte revised this gist May 30, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -100,7 +100,6 @@ global _start
    %macro call_func 1
    call %1
    add rsp, 0x8
    %endmacro
    _start:
  2. yellowbyte revised this gist Jan 18, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -65,14 +65,14 @@ template code (hello world):
    extern puts
    extern exit
    section .text
    global _start
    %macro call_func 1
    call %1
    add esp, 0x4
    %endmacro
    section .text
    global _start
    _start:
    push hello
    call_func puts
    @@ -95,14 +95,14 @@ template code (hello world):
    extern puts
    extern exit
    section .text
    global _start
    %macro call_func 1
    call %1
    add rsp, 0x8
    %endmacro
    section .text
    global _start
    _start:
    mov rdi, hello
    call_func puts
  3. yellowbyte revised this gist Jan 18, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -118,4 +118,6 @@ __NOTE__ :
    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
    * macro: a name that represents a snippet of code
    * define: a single-line macro
  4. yellowbyte revised this gist Jan 18, 2019. 1 changed file with 16 additions and 6 deletions.
    22 changes: 16 additions & 6 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -9,16 +9,18 @@ template code (hello world):
    section .text
    global _start
    %define system_call int 0x80
    _start:
    mov ebx, 0x1
    mov ecx, hello
    mov edx, helloLen
    mov eax, 0x4
    int 0x80
    system_call
    xor ebx, ebx
    mov eax, 0x1
    int 0x80
    system_call
    section .data
    hello db "Hello World", 0xa
    @@ -63,13 +65,17 @@ template code (hello world):
    extern puts
    extern exit
    %macro call_func 1
    call %1
    add esp, 0x4
    %endmacro
    section .text
    global _start
    _start:
    push hello
    call puts
    add esp, 0x4
    call_func puts
    mov eax, 0xa
    call exit
    @@ -89,13 +95,17 @@ template code (hello world):
    extern puts
    extern exit
    %macro call_func 1
    call %1
    add rsp, 0x8
    %endmacro
    section .text
    global _start
    _start:
    mov rdi, hello
    call puts
    add rsp, 0x8
    call_func puts
    mov rax, 0xa
    call exit
  5. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -103,9 +103,7 @@ _start:
    section .data
    hello db "Hello World"
    ```

    <br />

    ---
    __NOTE__ :
    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
  6. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -103,10 +103,10 @@ _start:
    section .data
    hello db "Hello World"
    ```

    <br />

    __NOTE__ :

    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
  7. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -104,6 +104,7 @@ section .data
    hello db "Hello World"
    ```
    <br />

    __NOTE__ :

    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
  8. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -104,9 +104,9 @@ section .data
    hello db "Hello World"
    ```
    <br />
    __NOTE__:
    __NOTE__ :

    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
  9. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -105,7 +105,8 @@ section .data
    ```
    <br />
    __NOTE__:
    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA

    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
  10. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -105,7 +105,7 @@ section .data
    ```
    <br />
    __NOTE__:
    * Assembly Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
    * Assembler Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
  11. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -102,4 +102,10 @@ _start:
    section .data
    hello db "Hello World"
    ```
    ```
    <br />
    __NOTE__:
    * Assembly Directives: instructions for the assembler (e.g. NASM) and not a part of the ISA
    * extern: declare a symbol which is defined in another module that will later be linked with current one
    * section: identifies the section the code you write will go into. Examples of common ones are .text, .data, and .bss
    * global: defines symbols such that other modules that EXTERN those symbols can correctly reference them after linking
  12. yellowbyte revised this gist Jan 16, 2019. 1 changed file with 26 additions and 0 deletions.
    26 changes: 26 additions & 0 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -74,6 +74,32 @@ _start:
    mov eax, 0xa
    call exit
    section .data
    hello db "Hello World"
    ```

    ### 64-bit ELF binary with libc
    how to assemble and link:
    ```bash
    nasm -f elf64 -o <filename>.o <filename>.asm
    ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o <filename> -lc <filename>.o
    ```
    template code (hello world):
    ```assembly
    extern puts
    extern exit
    section .text
    global _start
    _start:
    mov rdi, hello
    call puts
    add rsp, 0x8
    mov rax, 0xa
    call exit
    section .data
    hello db "Hello World"
    ```
  13. yellowbyte revised this gist Mar 3, 2018. No changes.
  14. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ### 32-bit ELF binary
    how to assemble &mdash; and link:
    how to assemble and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  15. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ### 32-bit ELF binary
    how to assemble &mdash and link:
    how to assemble &mdash; and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  16. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ### 32-bit ELF binary
    how to assemble -- and link:
    how to assemble &mdash and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  17. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ### 32-bit ELF binary
    how to assemble - and link:
    how to assemble -- and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  18. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ### 32-bit ELF binary
    how to assemble and link:
    how to assemble - and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  19. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## 32-bit ELF binary
    ### 32-bit ELF binary
    how to assemble and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    @@ -25,7 +25,7 @@ section .data
    helloLen equ $-hello
    ```

    ## 64-bit ELF binary
    ### 64-bit ELF binary
    how to assemble and link:
    ```bash
    nasm -f elf64 -o <filename>.o <filename>.asm
    @@ -52,7 +52,7 @@ section .data
    helloLen equ $-hello
    ```

    ## 32-bit ELF binary with libc
    ### 32-bit ELF binary with libc
    how to assemble and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
  20. yellowbyte revised this gist Feb 17, 2018. No changes.
  21. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 20 additions and 10 deletions.
    30 changes: 20 additions & 10 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ## 32-bit ELF binary
    how to compile:
    how to assemble and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
    @@ -25,10 +25,14 @@ section .data
    helloLen equ $-hello
    ```

    ##### 64-bit ELF binary
    ; nasm -f elf64 -o <filename>.o <filename>.asm
    ; ld -o <filename> <filename>.o
    ; template code: hello world
    ## 64-bit ELF binary
    how to assemble and link:
    ```bash
    nasm -f elf64 -o <filename>.o <filename>.asm
    ld -o <filename> <filename>.o
    ```
    template code (hello world):
    ```assembly
    section .text
    global _start
    @@ -46,11 +50,16 @@ _start:
    section .data
    hello db "Hello World", 0xa
    helloLen equ $-hello

    ##### 32-bit ELF binary with libc
    ; nasm -f elf32 -o <filename>.o <filename>.asm
    ; ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o <filename> -lc <filename>.o
    ; template code: hello world
    ```

    ## 32-bit ELF binary with libc
    how to assemble and link:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o <filename> -lc <filename>.o
    ```
    template code (hello world):
    ```assembly
    extern puts
    extern exit
    @@ -67,3 +76,4 @@ _start:
    section .data
    hello db "Hello World"
    ```
  22. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### 32-bit ELF binary
    ## 32-bit ELF binary
    how to compile:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
  23. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    ### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

    #### 32-bit ELF binary
    ### 32-bit ELF binary
    how to compile:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
  24. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    #### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc
    ### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

    ##### 32-bit ELF binary
    #### 32-bit ELF binary
    how to compile:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
    ```
    template code (hello world)
    template code (hello world):
    ```assembly
    section .text
    global _start
  25. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@ how to compile:
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
    ```
    ; template code: hello world
    template code (hello world)
    ```assembly
    section .text
    global _start
    @@ -24,6 +25,7 @@ _start:
    section .data
    hello db "Hello World", 0xa
    helloLen equ $-hello
    ```

    ##### 64-bit ELF binary
    ; nasm -f elf64 -o <filename>.o <filename>.asm
  26. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

    ##### 32-bit ELF binary
    * how to compile:
    how to compile:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  27. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

    ##### 32-bit ELF binary
    * how to compile:
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
  28. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,10 @@
    #### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

    ##### 32-bit ELF binary
    ; nasm -f elf32 -o <filename>.o <filename>.asm
    ; ld -m elf_i386 -o <filename> <filename>.o
    ```bash
    nasm -f elf32 -o <filename>.o <filename>.asm
    ld -m elf_i386 -o <filename> <filename>.o
    ```
    ; template code: hello world
    section .text
    global _start
  29. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ section .data
    hello db "Hello World", 0xa
    helloLen equ $-hello

    ; 64-bit ELF binary
    ##### 64-bit ELF binary
    ; nasm -f elf64 -o <filename>.o <filename>.asm
    ; ld -o <filename> <filename>.o
    ; template code: hello world
    @@ -44,7 +44,7 @@ section .data
    hello db "Hello World", 0xa
    helloLen equ $-hello

    ; 32-bit ELF binary with libc
    ##### 32-bit ELF binary with libc
    ; nasm -f elf32 -o <filename>.o <filename>.asm
    ; ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o <filename> -lc <filename>.o
    ; template code: hello world
  30. yellowbyte revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compiling_asm.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #### how to compile assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

    ; 32-bit ELF binary
    ##### 32-bit ELF binary
    ; nasm -f elf32 -o <filename>.o <filename>.asm
    ; ld -m elf_i386 -o <filename> <filename>.o
    ; template code: hello world