Structure of a NASM Program

Structure of a NASM Program

2021/02/14 Computer Engineering 0
     1                                            global    _start
     2                                  
     3                                            section   .text
     4 00000000 B801000000              _start:   mov       rax, 1                  ; system call for write
     5 00000005 BF01000000                        mov       rdi, 1                  ; file handle 1 is stdout
     6 0000000A 48BE-                             mov       rsi, message            ; address of string to output
     6 0000000C [0000000000000000] 
     7 00000014 BA0D000000                        mov       rdx, 13                 ; number of bytes
     8 00000019 0F05                              syscall                           ; invoke operating system to do the write
     9 0000001B B83C000000                        mov       rax, 60                 ; system call for exit
    10 00000020 4831FF                            xor       rdi, rdi                ; exit code 0
    11 00000023 0F05                              syscall                           ; invoke operating system to exit
    12                                  
    13                                            section   .data
    14 00000000 48656C6C6F2C20576F-     message:  db        "Hello, World", 10      ; note the newline at the end
    14 00000009 726C640A           

Leave a Reply

Your email address will not be published.