; File: printf2.asm ; ; Using C printf function to print ; ; Assemble using NASM: nasm -f elf printf2.asm ; ; Assembler style main function. ; Link with gcc: gcc -nostartfiles printf2.asm ; %define SYSCALL_EXIT 1 ; Declare some external functions ; extern printf ; the C function, we'll call SECTION .data ; Data section msg: db "Hello, world: %c", 10, 0 ; The string to print. SECTION .text ; Code section. global _start _start: push dword 97 ; an 'a' push dword msg ; address of ctrl string call printf ; Call C function add esp, 8 ; pop stack mov eax, SYSCALL_EXIT ; Exit. mov ebx, 0 ; exit code, 0=normal int 080H ; ask kernel to take over