; File: printf1.asm ; ; Using C printf function to print ; ; Assemble using NASM: nasm -f elf printf1.asm ; ; C-style main function. ; Link with gcc: gcc printf1.o ; ; 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 main main: push ebp ; set up stack frame mov ebp,esp push dword 97 ; an 'a' push dword msg ; address of ctrl string call printf ; Call C function add esp, 8 ; pop stack mov esp, ebp ; takedown stack frame pop ebp ; same as "leave" op ret