I was tinkering around a bit with putchar, push and pop.
When I tried to push the value of rcx, do something with it, call putchar and pop it back into rcx, I found that the value in rcx was changed to 0.
Like in the first bit of code.
For comparison, I made the second bit of code, where I push rcx, do something with it that is not putchar and pop it back into rcx, rcx still is at the value it was pushed at.
mov rcx, 123
push rcx
inc rcx
call [putchar]
pop rcx
call [putchar]
mov rcx, 123
push rcx
inc rcx
pop r12
call [putchar]
mov rcx, r12
call [putchar]
Does putchar actually clear the stack?
Does anyone know how to protect the stack (or at least the important part of it) from this?