I am writing a code that puts a value in memory and moves it to eax register to print. But _printf function is not working at all, there is no error and just nothing is shown on the screen.
This is the code.
section .data msg db "%d", 10, 0 section .text extern _printf global _main _main: push ebp mov ebp, esp mov byte , 100 mov eax, dword  push eax push msg call _printf leave ret
and I compiled with these three lines of command
nasm -f win32 memory.asm gcc memory.obj
I executed the exe file, it is the result
Nothing is printed on the screen. No error, no warning, but nothing is shown on the screen
I can't know the cause of this problem exactly. That's why I posted this question. But I thought about many reasons.
I'm guessing, it can be divided into three cases.
- Problem of _print function call process
- Problem with moving value to memory
- Problem with moving value of memory to eax
Problem of _print function call process
I checked that it is not the problem of printing part. If I just move 100 to the eax and print it out, 100 is printed well.
mov eax, 100 push eax push msg call _printf
Problem with moving value to memory
I don't think there is a problem with this.
This works without error and 100 is acceptable for byte size.
Problem with moving value of memory to eax
There might be a problem in this part.
Because I have always done like this when I move the value to eax, but it is my first time putting the value of memory into it. I wrote this code just by intuition without searching on the Internet. So, the form of this instruction may be wrong.
What I Want
 <- 100 eax <-  print eax and as a result 100
Put 100 in , put the value to the eax, and print 100 by printing eax. It is the result that I want.