Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .data
- msg db 'Anus!', 0x0A
- file db 'anus_out'
- section .text
- global _start
- _start:
- ;; SYS_OPEN
- mov rax, 2 ; System call, sys_open
- mov rdi, file ; 1st arg, filename
- mov rsi, 1 ; 2nd arg, flag: O_WRONLY
- mov rdx, 0 ; 3rd arg, mode NULL
- syscall
- ;; Jump if failed
- cmp rax, 0
- jng _open_fail
- mov rbx, rax ; Store the fd
- ;; SYS_WRITE
- mov rax, 1 ; System call, sys_write
- mov rdi, rbx ; 1st arg, writing fd
- mov rsi, msg ; 2nd arg, message
- mov rdx, 6 ; 3rd arg, length
- syscall
- ;; Jump if failed
- cmp rax, 0
- jng _write_fail
- ;; SYS_CLOSE
- mov rax, 3
- mov rdi, rbx
- syscall
- mov rdi, 0
- jmp _exit
- _open_fail:
- mov rdi, -1
- jmp _exit
- _write_fail:
- mov rdi, -2
- jmp _exit
- _exit:
- mov rax, 60
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement