I have the folowing code:
mov ecx, 0
mov eax, offset ReadWritten
RottenApple:
push ecx
push eax
push 0
push eax
push 1
push offset bytearray
push consoleOutHandle
call WriteConsole
pop eax
pop ecx
inc ecx
inc eax
cmp ecx, 10
jne RottenApple
The intention is to print, if the user input was "123456", fist 1, then 2, etc... But it only print 10 1's. Whats wrong with incrementing the offset,and why doesn't it make any diference?
Note that eax
is destroyed by the call to WriteConsole
(it will contain the return value) so you have to save it just like you do with ecx
.
Update:
On closer look, you are calling the WriteConsole
with wrong arguments. You want to increment the offset, as you say in the question, but you are not doing that.
Try something like:
mov ecx, 0
mov eax, offset bytearray
RottenApple:
push ecx
push eax
push 0
push offset ReadWritten
push 1
push eax
push consoleOutHandle
call WriteConsole
pop eax
pop ecx
inc ecx
inc eax
cmp ecx, 10
jne RottenApple