It appears that printf gets upset if the stack is not aligned properly to 4 bytes, so I found this to work:
Code:
#include <stdio.h>
typedef unsigned short WORD;
void outputstuff(unsigned int i)
{
printf("%u ",i);
fflush(stdout);
}
int main(int nArgs,char*sArgs[])
{
WORD i = 0;
__asm
{
looping:
movzx ecx, word ptr i
cmp ecx,256
jae breaker
push ecx
call outputstuff
add esp,4
add word ptr i,1
jmp looping
breaker:
}
return 0;
}
I added the fflush to make sure I would see the output immediately, rather than at the very end of the program.
--
Mats