Created
November 29, 2014 22:18
-
-
Save ianpreston/8d7ae5546dd75f21b041 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
; Assembly hello world for OSX | |
; So I can remember how to do basic shit in OSX | |
; | |
; $ nasm -g -f macho -o test.o test.asm | |
; $ ld -o a.out -e _main test.o -lSystem | |
bits 32 | |
section .data | |
message db "Hello, world!", 10, 0 | |
section .text | |
global _main | |
extern _printf | |
extern _exit | |
_main: | |
; Store argc and argv | |
pop eax | |
pop ebx | |
; 16-bit stack alignment | |
mov ebp, esp | |
and esp, 0xFFFFFFF0 | |
sub esp, 16 | |
;push message | |
mov dword[esp], message | |
call _printf | |
mov dword[esp], 0 | |
call _exit | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment