; From http://en.wikipedia.org/wiki/X86_assembly_language
;
; Homework:
;    1. This program always terminates with non-0 exit code,
;       as if an error occurs (check this with 'echo $?').
; 	This is a bug. Fix it.	
; 
;    2. Make this code execute /bin/sh via an exec-family syscall. 
;
; Build with:   nasm -f elf64 hello64.s
; Link with:    ld -o hello64 hello64.o     
;
BITS 64
section .text
global _start, write
write:
        mov    al, 1 ; write syscall
        syscall
        ret
_start:
        mov    rax, 0x0a68732f6e69622f ; /bin/sh\n
        push   rax
        xor    rax, rax
        mov    rsi, rsp
        mov    rdi, 1
        mov    rdx, 8
        call   write
 
exit: ; just exit not a function
        xor    rax, rax
        mov    rax, 60
        syscall

