I am attempting to use the _printf
function, and everything works OK except for one thing: it prints the result twice. The issue is that I am not receiving any errors other than the unexpected behavior. I attempted to add a null terminated character but was unable to change the result. However, that should not be an issue since if I am not incorrect, the string should be defaulted to make the string null terminated.
I am compiling the code with:
as --32 ./bin/assembly.asm -o ./bin/a.o
ld -m i386pe ./bin/a.o -o ./bin/a -lmsvcrt
The assembly code:
.section .text
.global _start
_start:
call main
movl %eax, %ebx
movl $1, %eax
.section .data
LC0:
.string "hello\0"
.section .text
main:
pushl %ebp
movl %esp, %ebp
sub $0, %esp
pushl $LC0
call _printf
add $4, %esp
movl $0, %eax
leave
ret
The output:
hellohello
I have tried to reinstall the msvcrt.dll
but that did not help, have also tried to restart the computer, have also tried to use puts
and putchar
but with the same result.