First off, you are using printf
wrong! printf
has a format parameter, printf docs get used to using it the correct way now, and it will cut down on bugs/bad things later. Uncontrolled format string, How can a Format-String vulnerability be exploited?
If you would read the docs, it would show you the format specifier to display characters instead of strings, but hey, one can ask a question without doing research or reading docs.
global main
extern printf, exit
section .data
hello db 'Hello', 0
hello_Len equ $ - hello
fmtstr db "%s", 10, 0
fmtchr db "%c", 10, 0
section .text
main:
push hello
push fmtstr
call printf
add esp, 4 * 2
xor ebx, ebx
mov esi, hello
PrintHello:
movzx eax, byte [esi + ebx]
push eax
push fmtchr
call printf
add esp, 4 * 2
inc ebx
cmp ebx, hello_Len - 1
jne PrintHello
push 0
call exit