Created
November 27, 2015 11:14
-
-
Save dnicolson/6f291af7ab9d93248cfa to your computer and use it in GitHub Desktop.
An example of making a syscall in assembly on OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; nasm -f macho64 mkdir.asm && ld -o mkdir mkdir.o && ./mkdir | |
%define SYSCALL_MKDIR 0x2000088 | |
%define SYSCALL_EXIT 0x2000001 | |
global start | |
section .text | |
start: | |
call mkdir | |
call exit | |
ret | |
mkdir: | |
mov rax, SYSCALL_MKDIR | |
mov rdi, directory | |
mov rsi, 0x1ED | |
syscall | |
exit: | |
mov rax, SYSCALL_EXIT | |
mov rdi, 0 | |
syscall | |
section .data | |
directory: db 'tmp', 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nasm -f macho64 mkdir.asm && ld -e start -static -o mkdir mkdir.o
correct way to build