The problem is that scanf
returns the number of items processed in eax
, thereby overwriting the 0
you have put in there previously. Since you read 1 item, eax
will be 1
and that explains why you get 10 when you run the code. You should move the mov eax, 0
down to after the scanf
and start ebx
from 0
too.
Other issues: you should use dd
for your c1
because an integer is 4 bytes, not 1. You should also zero terminate your format string and put the message
into the .data
section as well.