Hello, I want use the loop because it will dec ecx automaticly , but , the push/pop ecx before the call, crash....
for example:
mov rcx 10
LOOP_BEGIN:
push rcx
invoke funcitonXXX
pop rcx
loop LOOP_BEGIN
I'm confused about the stack...
Try pushing two registers, in order to keep the align 16.
Hi seasea,
Here is a quick example for you:
option casemap:none
EXTERN printf:PROC
EXTERN ExitProcess:proc
.data
string db 'This is a test.',13,10,0
.code
main PROC
LOCAL dummy:QWORD
LOCAL counter:QWORD ; aligned variable
sub rsp,20h
mov rcx,10
mov counter,rcx
loop_begin:
lea rcx,string
call printf
dec counter
jnz loop_begin
xor ecx, ecx
call ExitProcess
main ENDP
END
Answer is simple, don't use PUSH / POP in 64 bit. It can be done but you risk the problem you have. Use a LOCAL value to preserve the register.
LOCAL reg_ :QWORD
mov reg_, rcx
; do something with ECX
mov rcx, reg_
This completely avoids stack alignment issues.
Hi, seasea
it is the easy push rcx
push rcx
invoke funcitonXXX
pop rcx
pop rcx
It is that easy in general, but I wrote "try pushing" above because of the odd case where you bump into shadow space.
Ciao, jj!
scusami, ma in qualche modo non ho notato la tua risposta ... (https://wasm.in/styles/smiles_s/blush2.gif)
Sorry, I forgot it, the stack frame is aligned to a 16 byte. :redface:
Thank you very much, jj2007, Vortex, hutch--, and others. :t :icon14: