Assembly in Action

dreamersdw March 06, 2024 #Assembly

Assembly Language is not hard at all

hello world

        .section .rodata
msg:
        .ascii  "hello, world\n"

        .section .text
        .global _start
_start:
        # write(1, msg, msg_len)
        mov     $1, %rax                # system call 1 is write
        mov     $1, %rdi                # file handle 1 is stdout
        lea     msg(%rip), %rsi         # address of string to output
        mov     $13, %rdx               # number of bytes
        syscall

        # exit(0)
        mov     $60, %rax               # system call 60 is exit
        xor     %rdi, %rdi              # return code 0
        syscall