; hello.asm ; Glenn G. Chappell ; 25 Jan 2012 ; ; For CS 321 Spring 2012 ; Linux system call demo in x64_64 assembly (NASM syntax) ; NOTE: 64-bit. ; For 32-bit, change all r** registers to e**. section ".text" global main ; main ; Make a sys_write system call to print "Hello, world!" to stdout. main: ; Selector code for sys_write mov rax, 4 ; Parameters for sys_write mov rbx, 1 ;File descriptor: stdout mov rcx, msg ;Pointer to our string mov rdx, msgend-msg ;Length of our string ; Make the system call int 0x80 ; Return value of the system call is now in rax mov rax, 0 ;Function return value - all is well ret section ".data" ; Our string to print (0xa is '\n') msg: db 'Hello, world!', 0xa msgend: