Printf without newline in assembly
fflush() flushes buffered output in line or full-buffered stdio streams:
extern fflush
...
xor edi, edi ; RDI = 0
call fflush ; fflush(NULL) flushes all streams
...
Alternatively, mov rdi, [stdout]
/ call fflush
also works to flush only that stream. (Use default rel
for efficient RIP-relative addressing, and you'll need extern stdout
as well.)
Call fflush(stdout);
to display what's currently sitting in the buffers.
For Windows 32-bit mode (FASM):
push [_iob]
call [fflush] ; call into DLL. Callee-pops calling convention
GNU/Linux 32-bit mode (NASM)
extern fflush
extern stdout
...
push dword [stdout]
call fflush ; linker takes care of PLT stub for dynamic linking (in a non-PIE executable)
add esp, 4 ; caller-pops calling convention
etc...